New constant #PB_Shortcut for BindMenuEvent
Posted: Mon Oct 07, 2013 5:52 am
Consider the following snippet:
Here it was necessary to create a dummy popupmenu to allow the use of BindMenuEvent with AddKeyboardShortcut. If we could write:
then... well, you get the idea. Thanks for listening!
Code: Select all
Procedure callback1()
Debug "Right-arrow key pressed"
EndProcedure
OpenWindow(0,0,0,800,600,"Game",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
AddKeyboardShortcut(0, #PB_Shortcut_Right, 1)
CreatePopupMenu(0) ; dummy, we'll never add items to it or show it
; it exists only to allow the use of BindMenuEvent
BindMenuEvent(0, 1, @callback1())
Repeat:Until WaitWindowEvent() = #PB_Event_CloseWindow
Code: Select all
BindMenuEvent(#PB_Shortcut, <event>, @<callback>)