List of events

BlitzMax Forums/BlitzMax Beginners Area/List of events

Farflame(Posted 2009) [#1]
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?


Scienthsine(Posted 2009) [#2]
Can't find it in the online docs, but in the IDE help menu go here: Help>Modules>Events>Events


Farflame(Posted 2009) [#3]
Ah thanks, it's in there. Event_Keydown as I suspected, just gotta find out how to retrieve the code from it now :)


Scienthsine(Posted 2009) [#4]
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.


Farflame(Posted 2009) [#5]
Pity there's no examples, it doesn't even say how I access Eventdata... don't worry, I'll work it out :)


Scienthsine(Posted 2009) [#6]
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.


Farflame(Posted 2009) [#7]
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


Farflame(Posted 2009) [#8]
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?


Scienthsine(Posted 2009) [#9]
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




Farflame(Posted 2009) [#10]
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.


Scienthsine(Posted 2009) [#11]
Click in the window first to give it focus. Tell me if that doesn't work.


Farflame(Posted 2009) [#12]
Still nothing I'm afraid. The window does have focus and I just click/pasted your code into a new program. Very odd.


REDi(Posted 2009) [#13]
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



Farflame(Posted 2009) [#14]
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?


Zeke(Posted 2009) [#15]
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



Farflame(Posted 2009) [#16]
Cool, Sensitize_Keys is a new one to me too. Thought you'd spelt it wrong for a minute, but that code works :)


Scienthsine(Posted 2009) [#17]
Out of curiosity, what OS are you running Farflame?


Farflame(Posted 2009) [#18]
I'm running XP, would it make a difference?


Scienthsine(Posted 2009) [#19]
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.


Farflame(Posted 2009) [#20]
It is strange I agree :s