Page 1 of 1

How do you post custom gadget's events to the PB EventLoop?

Posted: Mon Mar 02, 2009 9:00 am
by Demivec
Here is a typical PB event loop that's been roughed out:

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
ForEver
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). :wink:

Posted: Mon Mar 02, 2009 9:56 am
by ts-soft
This is the simplest way to send custom messages

Code: Select all

Import ""
  PB_Gadget_SendGadgetCommand(hWnd, EventType)
EndImport


Posted: Tue Mar 03, 2009 2:30 am
by Demivec
Thankyou, it definately does the job. What file is it imported from? I know it's one that is already opened but without its name I won't be able to browse its other contents.

Posted: Tue Mar 03, 2009 10:55 am
by ts-soft
>> What file is it imported from?
Gadget.lib :wink: