Code:
;There is one large drawback with this procedure,
;gadget enumeration MUST start with 1 and not at 0 as many tend to do,
;the reason is that 0 is returned on failure or if no mouseover/hover occurs.
;so enumerate your gadgets as 1, 2, 3, 4 etc.
Procedure.l EventHoverGadget()
Protected cursor.POINT,hndl.l
If GetCursorPos_(cursor.POINT)
hndl=WindowFromPoint_(cursor\x,cursor\y)
If hndl
hndl=GetDlgCtrlID_(hndl)
If hndl
ProcedureReturn hndl
EndIf
EndIf
EndIf
ProcedureReturn 0
EndProcedure
OpenWindow(1,0,0,400,100,#PB_Window_ScreenCentered|#PB_Window_SystemMenu,"MouseOver example")
CreateGadgetList(WindowID())
ButtonGadget(1,10,10,380,20,"Button 1") ;Please note that the first gadgetid start with 1
ButtonGadget(2,10,30,380,20,"Button 2")
hover=0
oldhover=hover
Repeat
event=WindowEvent()
Select event
Case #WM_MOUSEMOVE
hover=EventHoverGadget()
If hover<>oldhover
Select hover
Case 1 : SetGadgetText(1,"Hover")
Case 2 : SetGadgetText(2,"Hover")
EndSelect
Select oldhover
Case 1 : SetGadgetText(1,"Button 1")
Case 2 : SetGadgetText(2,"Button 2")
EndSelect
oldhover=hover
EndIf
EndSelect
Delay(1)
Until event = #PB_Event_CloseWindow
Now let's hope something similar appear in a future PB version
