Yesterday, 01:11 AM
@Bplus
very nice multiple button menu application!
We can say that Pete is a good debugger! He has catched the queue of mouse input bug in a glance!
@Pete
my 2nd example of menu is already a sukerfish menu but it uses a voice/item of menu to go back...
now here I post a version using as control the click out of the menu area...
It is still in working both for modularizing menu management both for getting a better mouse input control...
for now you can see menu flickering if you continue to click on the menu item for submenu (Menu2 and Menu3)!
I think that I need to use an array for menu data for a simpler management of the menu system and a more accurate gathering of the mouse input.
I'll try to do these improvements as soon as I have more time...
very nice multiple button menu application!
We can say that Pete is a good debugger! He has catched the queue of mouse input bug in a glance!
@Pete
my 2nd example of menu is already a sukerfish menu but it uses a voice/item of menu to go back...
now here I post a version using as control the click out of the menu area...
It is still in working both for modularizing menu management both for getting a better mouse input control...
for now you can see menu flickering if you continue to click on the menu item for submenu (Menu2 and Menu3)!
I think that I need to use an array for menu data for a simpler management of the menu system and a more accurate gathering of the mouse input.
I'll try to do these improvements as soon as I have more time...
Code: (Select All)
Rem demo of menu with mouse selection
DefLng L
lwindow = _NewImage(800, 600, 32)
Screen lwindow
_Font 16
MenuItem$ = "First/Second/Third/Forth/Fifth/Menu2/Sixth/Seventh/Eighth/Ninth/"
Menu2$ = "1st/2nd/3rd/Menu3/4th/5th/6th/7th/8th/9th/"
Menu3$ = "3-1/3-2/3-3/3-4/3-5/3-6/3-7/3-8/3-9/"
item$ = ""
items2$ = ""
items3$ = ""
Do
Color _RGBA(6, 6, 127, 255), _RGBA(227, 55, 55, 255)
While _MouseInput: _PrintString (580, 300), " X" + Str$(_MouseX) + "/ Y" + Str$(_MouseY) + " " + "-" + item$ + Space$(8): Wend
Mx% = _MouseX
My% = _MouseY
mb% = _MouseButton(1)
If item2$ = "Menu3" Then
item3$ = ShowMenu$(Menu3$, 40 + (_FontWidth * 12 * 2), 20 + (_FontHeight * (a1% + a%)), Mx%, My%, mb%)
If mb% And item3$ = "" Then
item2$ = ""
mb% = 0
Line (40 + (_FontWidth * 12 * 2), 20 + (_FontHeight * a1%))-(40 + (_FontWidth * 12 * 3), 20 + (_FontHeight * (a% + a1% + b1%))), _RGBA(0, 0, 0, 255), BF
End If
ElseIf item$ = "Menu2" Then
item2$ = ShowMenu$(Menu2$, 40 + (_FontWidth * 12), 20 + (_FontHeight * a%), Mx%, My%, mb%)
a1% = Mx%
b1% = My%
If mb% And item2$ = "" Then
item$ = ""
mb% = 0
Line (40 + (_FontWidth * 12), 20 + (_FontHeight * a%))-(40 + (_FontWidth * 24), 20 + (_FontHeight * (a% + b%))), _RGBA(0, 0, 0, 255), BF
End If
Else
item$ = ShowMenu$(MenuItem$, 40, 20, Mx%, My%, mb%)
a% = Mx%
b% = My%
End If
Loop Until _MouseButton(2)
End
Function ShowMenu$ (Menu$, X%, Y%, Xm%, Ym%, Bm%)
ShowMenu$ = ""
Start% = 1
Ends% = 0
Nitem% = 0
item$ = ""
While InStr(Start%, Menu$, "/")
Ends% = InStr(Start%, Menu$, "/")
item$ = Mid$(Menu$, Start%, Ends% - Start%)
lbase$ = Space$(Int((12 - Len(item$)) / 2))
rbase$ = Space$(12 - (Len(lbase$ + item$)))
If MouseOver(X%, X% + (_FontWidth * 12), Y% + (_FontHeight * Nitem%), Y% + (_FontHeight * (Nitem% + 1)), Xm%, Ym%) Then
Color _RGBA(6, 238, 127, 255), _RGBA(0, 6, 255, 255)
_PrintString (580, 330), Space$(20)
_PrintString (580, 330), "Mouse over item" + Str$(Nitem% + 1) + lbase$ + item$ + rbase$
If Bm% Then
_PrintString (580, 360), Space$(20)
_PrintString (580, 360), "Selected item" + Str$(Nitem% + 1) + lbase$ + item$ + rbase$
ShowMenu$ = item$
Ntemp% = Nitem%
End If
Else
Color _RGBA(6, 6, 127, 255), _RGBA(227, 55, 55, 255)
End If
_PrintString (X%, Y% + (_FontHeight * Nitem%)), lbase$ + item$ + rbase$
Nitem% = Nitem% + 1
Start% = Ends% + 1
Wend
Xm% = Ntemp%
Ym% = Nitem%
End Function
Function MouseOver (X%, X1%, Y%, Y1%, Mx%, My%)
MouseOver = 0
If (Mx% >= X% And Mx% <= X1%) Then
If (My% > Y% And My% <= Y1%) Then MouseOver = 1
End If
End Function