End a program with cmd+q problems
Posted: Fri Aug 09, 2013 9:26 am
I'm a little lost 
Test1:
In this small example I can quit with cmd+q
Test2:
Here I'm able to do it also with cmd+q
As soon as i try with the keyboard lib (i would like to program a windowed game, that also can be quitted with cmd+q) it would not quit.
Test3:
This program cannot be terminated with cmd+q.
Can anyone tell my why? I think it's something with the keyboard library, but I don't get it. Thank you very much.

Test1:
In this small example I can quit with cmd+q
Code: Select all
OpenWindow(0,0,0,600,800,"test")
Debug "test"
Repeat
Repeat
event = WindowEvent()
Select event
Case #PB_Event_CloseWindow
quit = 1
Case #PB_Event_Menu
Select EventMenu()
Case -1
quit = 1
EndSelect
EndSelect
Until event = 0
Until quit
Here I'm able to do it also with cmd+q
Code: Select all
InitSprite()
OpenWindow(0,0,0,600,800,"test")
OpenWindowedScreen(WindowID(0),0,0,600,800)
Repeat
Repeat
event = WindowEvent()
Select event
Case #PB_Event_CloseWindow
quit = 1
Case #PB_Event_Menu
Select EventMenu()
Case -1
quit = 1
EndSelect
EndSelect
Until event = 0
ClearScreen(RGB(0,255,0))
FlipBuffers()
Until quit
As soon as i try with the keyboard lib (i would like to program a windowed game, that also can be quitted with cmd+q) it would not quit.
Test3:
This program cannot be terminated with cmd+q.
Code: Select all
InitKeyboard()
InitSprite()
OpenWindow(0,0,0,600,800,"test")
OpenWindowedScreen(WindowID(0),0,0,600,800)
Repeat
Repeat
event = WindowEvent()
Select event
Case #PB_Event_CloseWindow
quit = 1
Case #PB_Event_Menu
Select EventMenu()
Case -1
quit = 1
EndSelect
EndSelect
Until event = 0
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
quit = 1
EndIf
ClearScreen(RGB(0,255,0))
FlipBuffers()
Until quit