Code: Select all
#KB_Return = #PB_Shortcut_Return + 49152
Procedure KeyboardGyration()
Select EventType()
Case #PB_EventType_Focus
Debug "focus on window "
AddKeyboardShortcut(0, #PB_Shortcut_Return, #KB_Return)
Case #PB_EventType_LostFocus
Debug "lost focus on window "
RemoveKeyboardShortcut(0, #PB_Shortcut_Return)
EndSelect
EndProcedure
OpenWindow(0,0,0,640,480,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
TextGadget(#PB_Any, 10,20,100,16,"Enter Something:")
StringGadget(0, 110,20,300,20,"")
EditorGadget(1,10,50,400,400)
SetActiveGadget(0)
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
Case 0
EventTyp.l = EventType()
KeyboardGyration()
EndSelect
Case #PB_Event_Menu
Select EventMenu()
Case #KB_Return
SetActiveGadget(1)
EndSelect
EndSelect
Until EventID = #PB_Event_CloseWindow
Now, I took this code sample *only* one step further. Its broken and *logically* speaking, I see nothing wrong with what I did, but grant you I am a dummy so please explain why what I did is wrong, or confirm this is a bug. I *believe* now this is the origin of all my problems upgrading from v4.20 to 4.60
Run it in the debugger as before and watch what happens when click the debugger window to force the sample window to lose focus. You will NOT see it post ''lost focus on window'':
Code: Select all
Global EventTyp.l
#KB_Return = #PB_Shortcut_Return + 49152
Procedure KeyboardGyration()
Select EventTyp.l
Case #PB_EventType_Focus
Debug "focus on window "
AddKeyboardShortcut(0, #PB_Shortcut_Return, #KB_Return)
Case #PB_EventType_LostFocus
Debug "lost focus on window "
RemoveKeyboardShortcut(0, #PB_Shortcut_Return)
EndSelect
EndProcedure
OpenWindow(0,0,0,640,480,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
TextGadget(#PB_Any, 10,20,100,16,"Enter Something:")
StringGadget(0, 110,20,300,20,"")
EditorGadget(1,10,50,400,400)
SetActiveGadget(0)
Repeat
EventID = WaitWindowEvent()
liveWin = GetActiveWindow() ; subroutines listedd here in the main loop.
EventTyp.l = EventType()
Select liveWin
Case 0
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
Case 0
EventTyp.l = EventType()
KeyboardGyration()
EndSelect
Case #PB_Event_Menu
Select EventMenu()
Case #KB_Return
SetActiveGadget(1)
EndSelect
EndSelect
EndSelect
Until EventID = #PB_Event_CloseWindow