DesktopMouseX/Y?

BlitzMax Forums/BlitzMax Beginners Area/DesktopMouseX/Y?

taxlerendiosk(Posted 2005) [#1]
Is there a way to *get* the mouse position values that you can set with MoveMouse()?


Mark Tiffany(Posted 2005) [#2]
GadgetX(Desktop()) ought to work, but last time I checked, it didn't.


Eric(Posted 2005) [#3]
MaxGUI
Global MX:Int;MY:Int
Select EventID()
   Case Event_MouseMove
	MX=EventX()
	MY=EventY()
End Select



klepto2(Posted 2005) [#4]
Strict 

Local window:TGadget

window=CreateWindow("My Window",40,40,320,240)
Local P:TGadget = CreatePanel(0,0,ClientWidth(window),ClientHeight(window),Window,PANEL_ACTIVE)
While True

	WaitEvent 
	Print CurrentEvent.ToString()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			End
		Case EVENT_MOUSEMOVE
			SetStatusText(window,EventX()+ ":" + EventY() )
		Case EVENT_WindowSize
			SetGadgetShape(P,0,0,ClientWidth(window),ClientHeight(window))
	End Select
Wend



taxlerendiosk(Posted 2005) [#5]
No, no, not inside the application window - on the Desktop. I want to move a window to where the mouse is, and to do that I need the mouse's co-ordinates relative to the top left corner of the screen. Adding GadgetX/Y to window co-ordinates won't help because it won't be offset by the size of the window title bar/edge. There should be a way to do this, MoveMouse can *set* the values.

Edit: Also, klepto:
		Case EVENT_WindowSize
			SetGadgetShape(P,0,0,ClientWidth(window),ClientHeight(window))

Another way to do this (though you might already know and prefer to do it your way) is:
SetGadgetLayout P,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED

...once, after you create it.


klepto2(Posted 2005) [#6]
Yes, I alread know that, but forget it with this sample.
Maybe, this is what you are looking for:

Win32 only:
Strict 

Local window:TGadget
Global PT: POINT = New POINT

GetCursorPos_( pt )

window=CreateWindow("My Window",pt.x,pt.y,200,300)


While True
	GetCursorPos_( pt )
	SetStatusText(Window,pt.x + " : " + pt.y)
	
	WaitEvent 
	
	Print CurrentEvent.ToString()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			End
	End Select
Wend

?Win32
	Extern "Win32"
		Function GetCursorPos_(lpPoint:Byte Ptr) = "GetCursorPos@4"
	End Extern
?

Type POINT
	Field x%
	Field y%
End Type



taxlerendiosk(Posted 2005) [#7]
Aha! Yeah, that looks like it, thank you. Surely Cocoa and FLTK have equivalent functions, this should be made an official function...


taxlerendiosk(Posted 2005) [#8]
What about getting the screen position of gadgets, is that as easy? I suppose I could iterate back through using GadgetGroup(), adding up all the GadgetX()'s, but that would still have the titlebar/sidebar problem.