How do you post custom gadget's events to the PB EventLoop?
Posted: Mon Mar 02, 2009 9:00 am
Here is a typical PB event loop that's been roughed out:
Examining posts in the forum I know how to post custom events to the message queue read by the PB Event loop. Want I would like to do is post events that can be detected for a particular gadget (i.e. having a #PB_Event_Gadget type) and then being able to work with EventGadget() and EventType(). How can I accomplish this?
Would this be a case of trying to squeeze too much out of these functions? Or would it result in something that would break in a future PB version? If so I will have to make do with custom_events for the custom_gadgets involved. It just wouldn't make much sense to have to check for events from gadgets in more than one place (if I can avoid it).
Code: Select all
Repeat
event = WaitWindowEvent(10)
If event = #PB_Event_CloseWindow
Break
ElseIf event = #PB_Event_Menu
If EventMenu() = #Shortcut_Escape: Break: EndIf
ElseIf event = #PB_Event_Gadget
Select EventGadget()
Case #gadget_1
Select EventType()
Case #PB_EventType_LeftClick
;Do something
Case #PB_EventType_RightClick
;Do something
EndSelect
Case #gadget_2
;Do something
EndSelect
ElseIf #customEvent_1
;Do something
ElseIf #customEvent_2
;Do something
EndIf
ForEverWould this be a case of trying to squeeze too much out of these functions? Or would it result in something that would break in a future PB version? If so I will have to make do with custom_events for the custom_gadgets involved. It just wouldn't make much sense to have to check for events from gadgets in more than one place (if I can avoid it).