MaxGUI 101 - EVENT_MOUSEMOVE not firing?

BlitzMax Forums/MaxGUI Module/MaxGUI 101 - EVENT_MOUSEMOVE not firing?

jonwalker(Posted 2009) [#1]
Hi All,

Stupid question no doubt! I can't find any examples, tutorials or help on this topic. How to get the EVENT_MOUSEMOVE event to fire when over a window?

I have:
SuperStrict

Import MaxGui.Drivers

Local Window1:TGadget = CreateWindow("Test Mouse Move", 318, 143, 494, 316, Null, WINDOW_TITLEBAR | WINDOW_RESIZABLE | WINDOW_STATUS | WINDOW_CLIENTCOORDS | WINDOW_CENTER)

Print "start"

Repeat
WaitEvent()
Select EventID()
Case EVENT_WINDOWCLOSE
Select EventSource()
Case Window1
Print "end"
End
End Select

Case EVENT_MOUSEMOVE
Select EventSource()
Case Window1
Print "EVENT_MOUSEMOVE" ' not getting to this line?
End Select
End Select
Forever

When wiggling the mouse over the window I would imagine it would get to the Print "EVENT_MOUSEMOVE" line. However this isn't being called. Do I need to somehow enable events for the Window? Any ideas? :o)

Thanks, Jon


SebHoll(Posted 2009) [#2]
The easiest way is with an active panel (specify the PANEL_ACTIVE flag as the style parameter for CreatePanel()):

Import MaxGui.Drivers

Strict 

AppTitle = "Mouse Capture App"

Local window:TGadget = CreateWindow(AppTitle,40,40,320,240)

Local panel:TGadget = CreatePanel(0,0,ClientWidth(window),ClientHeight(window),window,PANEL_ACTIVE)
SetGadgetLayout panel,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED

Repeat
	WaitEvent() 
	Print CurrentEvent.ToString()
	Select EventID()
		Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE
			End
	End Select
Forever

You can also use SetGadgetSensitivity() command to enable similar functionality on other child gadgets (such as textfields, buttons, labels etc.), or you can use a graphics context (see CreateCanvas()) if you are planning on doing 2D drawing too. In the latter case, Max2D users may find themselves more comfortable if they add a call to EnablePolledInput() to the top of their source code, so that the standard MouseX(), MouseY(), etc. commands work as expected.

Hope this helps!


jonwalker(Posted 2009) [#3]
Ah ha! So you need a panel :o) Thanks SebHoll! :o)

Jon