Running GUI checks alongside regular code
BlitzMax Forums/BlitzMax Programming/Running GUI checks alongside regular code
| ||
I'm converting a Blitz+ project over to Max, and I'm experiencing a few problems. In my B+ project, my loop consisted of a series of Event checks, followed by canvas clearing, then my own routines (update graphics, keychecks, etc), followed by canvas flipping. This doesn't seem to work in Max; the Event checks are processed fine, but the bits and pieces at the bottom of the code loop don't seem to work. Are there known problems running my own KeyDown checks after Event checks? |
| ||
You will need to post code. |
| ||
A cut-down version...Repeat WaitEvent() Select EventID() '---------------------------------------------------------------------------------------------------- MENUS Case EVENT_MENUACTION Select EventData() Case 6 load() End Select '---------------------------------------------------------------------------------------------------- TOOLBAR Case EVENT_GADGETACTION If EventSource()=toolbar Select EventData() Case 0 Print "test" End Select EndIf End Select '---------------------------------------------------------------------------------------------------- CODE LOOP SetGraphics CanvasGraphics(canvas) Cls control() update_map() Flip If KeyHit(KEY_ESCAPE) End EndIf Until EventID () = EVENT_WINDOWCLOSE control() is merely a series of KeyDown checks, and UpdateMap just draws a tilemap. |
| ||
Ah. I get the impression that KeyDown and KeyHit won't work properly in GUI mode... :/ |
| ||
^ Correct. From Help's "Polled input" section, which includes KeyDown and KeyHit: The functions in this module are only available when your program is running in Graphics mode. When working on GUI applications, you will need to use events. I never used BlitzPlus, but since you're already doing event handling, it shouldn't be too bad to add in key handling when converting to Max. Some of the potentially useful EventIDs from Help's "Event objects" section: EVENT_KEYDOWN - Key pressed. Event data contains keycode EVENT_KEYUP - Key released. Event data contains keycode EVENT_HOTKEYHIT - Hot key hit. Event data and mods contains hotkey keycode and modifier |