EventX() EventY()
BlitzPlus Forums/BlitzPlus Beginners Area/EventX() EventY()
| ||
| I've been having trouble getting some code to work. I was originally using MouseX() and MouseY() to interact with a canvas, unfortunately, as I have multiple canvases and such in my GUI, MouseX() and MouseY() only returns values based on the canvas they are referred to and don't actually tell you if the mouse is on the canvas or not. I later ran into what looked like the solution by using id=waitevent() if id=$201;;if the mouse clicks if EventSource()=canvasThatIWant if EventData()=LeftOrRightClick But whenever I try to use the mx=EventX() my=EventY() to track the mouse location and see what its actually clicking in the canvases, it always returns a 0. How does EventX() and EventY() work? |
| ||
Here's an example of what you can do with EventX() and EventY():; create a window
win=CreateWindow("Move the mouse over the window",100,100,400,300,0,9)
cnv1=CreateCanvas(10,10,100,100,win)
cnv2=CreateCanvas(120,120,250,150,win)
; and set the status text
SetStatusText win,"Move the mouse over the window"
; a small event loop
Repeat
id = WaitEvent()
Select id
Case $803 ; exit on window close event
Exit
Case $203 ; update the status on gadget action
select eventsource()
case cnv1
SetStatusText win,"Canvas1: "+EventX() + " x " + EventY()
case cnv2
SetStatusText win,"Canvas2: "+EventX() + " x " + EventY()
end select
End Select
Forever
End ; bye!Hope this helps! :) |