WaitWindowEvent()
Syntax
Event = WaitWindowEvent([Timeout])Description
Wait until an event occurs. It's the same function as WindowEvent() but locks the program execution, which is very important in a multitasking environment.
An optional timeout (in milliseconds) can be specified, which causes the function to return after the specified amount of time if no events are occuring.
An application should always use this command instead of WindowEvent() if possible. For more information, see the documentation of WindowEvent().
Notes:
When opening a Window from a thread, the thread must also call WindowEvent() or WaitWindowEvent() in a loop to process events for this window, as window events are not sent between different threads.
WaitWindowEvent() can only be called once per event loop, because else events will be "lost" (every event can only be processed once and isn't available anymore for a second time after first processing).
Basic example:If OpenWindow(0, 0, 0, 230, 90, "Event handling example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) If CreateGadgetList(WindowID(0)) ButtonGadget (1, 10, 10, 200, 20, "Click me") CheckBoxGadget(2, 10, 40, 200, 20, "Check me") EndIf If CreateMenu(0, WindowID(0)) MenuTitle("Menu") MenuItem(1, "Item 1") MenuItem(2, "Item 2") MenuItem(3, "Item 3") EndIf Repeat Event = WaitWindowEvent() Select Event Case #PB_Event_Gadget Select EventGadget() Case 1 : Debug "Button 1 clicked!" Case 2 : Debug "Button 2 clicked!" Case 3 : Debug "Button 3 clicked!" EndSelect Case #PB_Event_Menu Select EventMenu Case 1 : Debug "Menu item 1 clicked!" Case 2 : Debug "Menu item 2 clicked!" Case 3 : Debug "Menu item 3 clicked!" EndSelect EndSelect Until Event = #PB_Event_CloseWindow EndIf
Supported OS
All