How close a window with the escape key?
BlitzMax Forums/BlitzMax Beginners Area/How close a window with the escape key?
| ||
Hi, only question: How close a window with the escape key? |
| ||
A graphics window or a maxgui window? If it's a max2d window then your main would look like While not Keyhit(key_escape) cls ...other stuff flip wend if its a maxgui window then you could use SetHotKeyEvent. but don't. |
| ||
Hi, I'm working on MaxGUI, I will try to set KeyEvent. |
| ||
Best way in MaxGUI is to create a button with the BUTTON_CANCEL property - when its containing window has focus, pressing Esc will automatically "press" that button. You can then close the window in the response to that button's event. If you don't want a visible cancel button, put it somewhere outside the window's render area (like -500, -500) and it should be invisible. |
| ||
With MaxGUI you can have a main loop that ends on KeyHit(KEY_ESCAPE) like GW showed. Then for the main loop you do something like this.While Not KeyDown(KEY_ESCAPE) WaitEvent() Select EventID() Case EVENT_WINDOWCLOSE End Case EVENT_WINDOWSIZE Case EVENT_WINDOWACTIVATE Case EVENT_TIMERTICK RedrawGadget can Case EVENT_GADGETPAINT DrawText "Testing Max2d",0,0 Flip EndSelect Wend |
| ||
It makes more sense to me to process incoming key press events in the same scope as other event types.Repeat WaitEvent() Select EventID() Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE End Case EVENT_WINDOWSIZE Case EVENT_WINDOWACTIVATE Case EVENT_TIMERTICK RedrawGadget can Case EVENT_KEYDOWN 'Wrap event processing in a function for something cleaner. Select EventData() Case KEY_ESCAPE End End Select End Select Forever |