12-24-2024, 10:00 AM
Hi friends
thanks for feedbacks
@Bplus
thank you
@Pete
Yes I got the bug
you can see a toggle flickering of the 2 texts of menu item highlighted and you can see the 2 menu items highlighted...
the cause is the ovelapping of Y dimension of the mouse
BUUUT if we take away the two = in the control of the position of MouseY we get the opposite mistake/bug , if we point with the mouse on the border between the 2 items no item has been highlighted!
the solution is to delete only one of the 2 = in the control of the position of MouseY.
here the working code:
Postscript:
yeah I mispelled ninth, now it is correct.
Yes nono is ninth in italian but if I press too much on the keyboard I can get with a n more nonno (grandfather)
thanks for feedbacks
@Bplus
thank you
@Pete
Yes I got the bug
you can see a toggle flickering of the 2 texts of menu item highlighted and you can see the 2 menu items highlighted...
the cause is the ovelapping of Y dimension of the mouse
BUUUT if we take away the two = in the control of the position of MouseY we get the opposite mistake/bug , if we point with the mouse on the border between the 2 items no item has been highlighted!
the solution is to delete only one of the 2 = in the control of the position of MouseY.
here the working code:
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/Sixth/Seventh/Eighth/Ninth/"
Do
Color _RGBA(6, 6, 127, 255), _RGBA(227, 55, 55, 255)
While _MouseInput: _PrintString (300, 300), " X" + Str$(_MouseX) + "/ Y" + Str$(_MouseY) + " ": Wend
Mx% = _MouseX
My% = _MouseY
Mb% = _MouseButton(1)
ShowMenu MenuItem$, 40, 20, Mx%, My%, Mb%
Loop Until _MouseButton(2)
End
Sub ShowMenu (Menu$, X%, Y%, Xm%, Ym%, Bm%)
Start% = 1
Ends% = 0
Nitem% = 0
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 (300, 330), "Mouse over item" + Str$(Nitem% + 1) + lbase$ + item$ + rbase$
If Bm% Then _PrintString (300, 360), "Selected item" + Str$(Nitem% + 1) + lbase$ + item$ + rbase$
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
End Sub
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
Postscript:
yeah I mispelled ninth, now it is correct.
Yes nono is ninth in italian but if I press too much on the keyboard I can get with a n more nonno (grandfather)