Page 1 of 1

Checking mouse pos (Click button)

Posted: Tue Feb 10, 2009 2:14 pm
by Frostfalk
I did a quick search here on the forums and looked through the documentation. But I haven't found what I'm looking for. In the documentation, I saw only these commands:

Code: Select all

getX( )   	 Gets the current x-position of the mouse.
getY( ) 	Gets the current y-position of the mouse.
	
getPosition( ) 	Gets the current position of the mouse.
setPosition( x, y ) 	Sets the current position of the mouse.
	
isDown( button ) 	Checks whether a certain button is down.
	
setVisible( visible ) 	Controls cursor visbility.
isVisible( ) 	Checks cursor visbility. 
But there is one thing that bugs me. Is there no way to check where the cursor is? I'm supposed to make a clickable button, but I need to check if the cursor is on the button. I'm sure this one is quite easy, but I'm a novice so go easy on me. ^^

Please help this little guy out; will ya?

EDIT - Changed the Thread Title to make it fit the subject even more.

Re: Checking mouse pos (Click button)

Posted: Tue Feb 10, 2009 2:40 pm
by bartbes
What's wrong with getX(), getY() and/or getPosition(), they do what you want. And if you want to check in the mousepressed callback it's even easier as it gets the position of the click as arguments.

Re: Checking mouse pos (Click button)

Posted: Tue Feb 10, 2009 2:45 pm
by Frostfalk
Thanks, I took a deeper look into the callback and it seems my answer is in there. I didn't see it at first. I'll try again and report back if I encounter more trouble.