Mouse position MaxGUI

BlitzMax Forums/BlitzMax Programming/Mouse position MaxGUI

jamesmintram(Posted 2006) [#1]
Hi everythone, what is the best way to get the mouse position in a MaxGUI app?
I tried mousex() but it doesnt work, and I cant see anything in the docs (but im pretty knackerd).

Cheers
James


Diablo(Posted 2006) [#2]
i dont know of a way to get it when its not on a active canvas but under EVENT_MOUSEMOVE or somthing like that you can use event.x and event.y


Dreamora(Posted 2006) [#3]
Which you then could write into a global coord object.


assari(Posted 2006) [#4]
Take a look at this Tutorial 12: Canvas, Events and 2D Graphics for how to use mouse events.


klepto2(Posted 2006) [#5]
The easiest way would be something like this.

Global Window:TGadget = CreateWindow(MousTest,20,20,800,600)
Global Panel:TGadget = CreatePanel(0,0,ClientWidth(window),ClientHeight(window),window,PANEL_ACTIVE)


EnablePolledInput() 'Important to activate the normal Key and Mouse Commands


Repeat

WaitEvent()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			End
	End Select

SetStatusText(window,MouseX()+":"+MouseY())


Forever



jamesmintram(Posted 2006) [#6]
Thank you very much guys.


Dreamora(Posted 2006) [#7]
klepto: yes it would be the easiest, but it defeats the event based programming which is indeed a "must have" for actual apps (I really hate apps that don't work this way because they suck my notebook accu empty just because of stupid programmers which don't wait for events)
Intel has an interesting article on this on their page which shows that others than waitevent based use far more power (factor 10) for the same work done.


klepto2(Posted 2006) [#8]
Dreamora, you're right about this. It is just the easiest way.
And BTW: PolledInput makes nothing different, it just waits for an event. But seriously it takes every related Event.

But it is useful for converting existing apps to the eventbased system. ie: you want to have your Graphics app running in a canvas. With EnablePolledInput() you could nearly
let it as it is.


JoshK(Posted 2006) [#9]
Function MouseX(gadget:tgadget=Null)
If Not gadget gadget=Desktop()
hwnd=QueryGadget(gadget,GADGET_HWND)
Local lpPoint[2]
GetCursorPos lpPoint
ScreenToClient hwnd,lpPoint
Return lpPoint[0]
End Function

Function MouseY(gadget:tgadget=Null)
If Not gadget gadget=Desktop()
hwnd=QueryGadget(gadget,GADGET_HWND)
Local lpPoint[2]
GetCursorPos lpPoint
ScreenToClient hwnd,lpPoint
Return lpPoint[1]
End Function