keyboard shortcut

BlitzMax Forums/BlitzMax Beginners Area/keyboard shortcut

jhocking(Posted 2007) [#1]
Okay I am sure this is buried in the documentation somewhere and I just can't find it, but how do you do the keyboard shortcut to quit? Y'know, Control+Q on Windows and Command+Q on Mac.


AltanilConard(Posted 2007) [#2]
Assuming you ask how to close an application created with BMax, I don't think it is possible to quit it like that (at least not when you're inside a loop). You could try something like "If KeyDown(KEY_LCONTROL) And KeyHit(KEY_Q) Then Exit"
I'm not totally sure though.


jhocking(Posted 2007) [#3]
Yeah that's what I meant. I see an event for hotkeys and MODIFIER_COMMAND, how do those work?


AltanilConard(Posted 2007) [#4]
http://blitzmax.com/Community/posts.php?topic=68044#760212
Someone posted a small example there that might help.


jhocking(Posted 2007) [#5]
Interesting. I can use Control+Q to quit on a Mac, but Command+Q is ignored. Presumably that's because the operating system is already "trapping" that event. How can I make that quit? People are going to be expecting that since that's standard for Mac applications.


SebHoll(Posted 2007) [#6]
You might want to have a look at the AppTerminate() function that returns True if the user has requested the application to close. On a Mac, this is probably going to be set to True if you use the Command+Q shortcut option.


LAB[au](Posted 2007) [#7]
ALT+F4 is the standard Win OS shortcut to quit, at least it's the one I use.


jhocking(Posted 2007) [#8]
Thanks for pointing out that command Seb, I didn't know about that. Unfortunately, polled input commands don't work with GUI stuff, I need to know how to detect that with events. Although you give me a big clue; perhaps there's an AppTerminate event?

Also, I just noticed the GUI editor in your sig. I'll have to check that out, it would have saved me a lot of time setting up the buttons on the editor I'm working on!


tonyg(Posted 2007) [#9]
You might be able to use enablepolledinput().
Don't think it's in the documentation but do a search as there has been some discussion about it.


jhocking(Posted 2007) [#10]
Righto, Seb's suggestion pointed me toward the answer I needed. I didn't notice it before when looking at the events list, but there is an EVENT_APPTERMINATE that triggers when you use the default Quit shortcut for the OS. Thanks Seb!