look at this:
Code: Select all
If InitSprite() And InitKeyboard() And OpenWindow(0, 0, 0, 640, 480, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "test") And OpenWindowedScreen(WindowID(0), 0, 0, 640, 480, 0, 0, 0)
Repeat
WinEvent.l = WindowEvent()
If WinEvent = 0
Delay(1)
EndIf
ExamineKeyboard()
Until WinEvent = #PB_Event_CloseWindow Or KeyboardReleased(#PB_Key_Escape)
EndIf
End
2.) switch to another app due alt+tab or mouseclick, so that our app becomes inactive, but dont release the escape key
3.) switch back to our app due alt+tab or mouseclick, so that our app becomes active again
now the app will close because our app thinks the escape key was released, while we are stil holding down the escape key.
try this, with and without ExamineKeyboard(). without ExamineKeyboard() it works the way it should, like in every non-pb game.
Code: Select all
If InitSprite() And InitKeyboard() And OpenWindow(0, 0, 0, 640, 480, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "test") And OpenWindowedScreen(WindowID(0), 0, 0, 640, 480, 0, 0, 0)
Repeat
WinEvent.l = WindowEvent()
If WinEvent = 0
Delay(1)
EndIf
If GetForegroundWindow_() = WindowID(0)
;ExamineKeyboard()
If KeyEscape = #True
If GetAsyncKeyState_(#VK_ESCAPE) = #False
Break
EndIf
ElseIf GetAsyncKeyState_(#VK_ESCAPE)
KeyEscape = #True
EndIf
EndIf
Until WinEvent = #PB_Event_CloseWindow
EndIf
End
Code: Select all
If InitSprite() And InitKeyboard() And OpenWindow(0, 0, 0, 640, 480, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "test") And OpenWindowedScreen(WindowID(0), 0, 0, 640, 480, 0, 0, 0)
Repeat
If GetForegroundWindow_() = WindowID(0)
ExamineKeyboard()
If KeyEscape = #True
If KeyboardPushed(#PB_Key_Escape) = #False
Break
EndIf
ElseIf KeyboardPushed(#PB_Key_Escape)
KeyEscape = #True
EndIf
EndIf
WinEvent.l = WindowEvent()
If WinEvent = 0
Delay(1)
EndIf
Until WinEvent = #PB_Event_CloseWindow
EndIf
End
nco2k