List of events
BlitzMax Forums/BlitzMax Beginners Area/List of events
| ||
| If there a list showing all the events anywhere, I can find one? I've noticed that when I use a MaxGUI window, it doesn't respond to normal Blitz KeyDown commands, so presumably keydown is an event for a MaxGUI window? |
| ||
| Can't find it in the online docs, but in the IDE help menu go here: Help>Modules>Events>Events |
| ||
| Ah thanks, it's in there. Event_Keydown as I suspected, just gotta find out how to retrieve the code from it now :) |
| ||
| EDIT Says EventData contains the keycode. You could get that field directly from the TEvent, or use the functions under Help>Events>Event Queue EventData() for keycode. |
| ||
| Pity there's no examples, it doesn't even say how I access Eventdata... don't worry, I'll work it out :) |
| ||
| haha, ya... I've been gone a while... doesn't seem like the documentation has gotten any better. Let me know if you don't get it after a while. I haven't really done any gui stuff with bmax, but I could probably whip up an example. |
| ||
| Hehe, it would really speed things up with good documentation, but there's some good tutorials on here so I'll find it somewhere in there I'm sure..... just a pain to be stuck for an hour on something so simple that a 1 line example would have solved :p |
| ||
| Well lol, I still haven't worked this one out, been getting on with other stuff. Could someone give me a quick code example of how to detect a keypress/keydown in a MaxGUI event loop? |
| ||
| Ok, whipped up something. What you were probley getting stuck on was that bmax doesn't seem to get most events for just a window, a canvas was needed for me. Try this out with and without the canvas and you'll see what I mean. EDIT Ohh and they do seem to be ascii codes, so should be easy to use.
SuperStrict
Import MaxGUI.Drivers
Local window:TGadget
Local canvas:TGadget
window=CreateWindow("My Window",40,40,320,240)
canvas=CreateCanvas(0,0,ClientWidth(window),ClientHeight(window),window)
While True
WaitEvent
Select EventID()
Case EVENT_WINDOWCLOSE
End
Case EVENT_KEYDOWN
Print EventData()
End Select
Wend
|
| ||
| Hmm , it's not working for me. Even if I replace 'Print EventData()' with a straightforward 'End', nothing happens, no matter which key I press. |
| ||
| Click in the window first to give it focus. Tell me if that doesn't work. |
| ||
| Still nothing I'm afraid. The window does have focus and I just click/pasted your code into a new program. Very odd. |
| ||
Try this...
SuperStrict
Import MaxGUI.Drivers
Local window:TGadget=CreateWindow("My Window",40,40,320,240)
Local canvas:TGadget=CreateCanvas(0,0,ClientWidth(window),ClientHeight(window),window)
While True
ActivateGadget(canvas)
WaitEvent
Select EventID()
Case EVENT_WINDOWCLOSE
End
Case EVENT_KEYDOWN
Print EventData()
End Select
Wend
|
| ||
| Ah yes, ActivateGadget was the key. Why do it need to be activated in the Canvas? I notice it doesn't work if I change it to ActivateGadget(window). So basically, each time I want to check for a keypress, I need to make sure the Canvas... or some other control.... is focused first? |
| ||
or try this:
SuperStrict
Import MaxGUI.Drivers
Local window:TGadget
Local canvas:TGadget
window=CreateWindow("My Window",40,40,320,240)
canvas=CreateCanvas(0,0,ClientWidth(window),ClientHeight(window),window)
SetGadgetSensitivity(window , SENSITIZE_KEYS)
While True
WaitEvent
Select EventID()
Case EVENT_WINDOWCLOSE
End
Case EVENT_KEYDOWN
Print EventData()
End Select
Wend
|
| ||
| Cool, Sensitize_Keys is a new one to me too. Thought you'd spelt it wrong for a minute, but that code works :) |
| ||
| Out of curiosity, what OS are you running Farflame? |
| ||
| I'm running XP, would it make a difference? |
| ||
| I'm just wondering why we have different behavior with the same code. I was running 7 when I wrote the above, but it should behave the same under xp... meh... guess it's water under the bridge now anyway. |
| ||
| It is strange I agree :s |