Recieve Mouse Move and Mouse Click?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Guest

Recieve Mouse Move and Mouse Click?

Post by Guest »

Hi! Is it possible to check if the mouse move and if a mouse button state changes? I want to move a node when the right button is pressed an the mousepointer moves.

regards, Tom
DarkWood_Neo
Posts: 52
Joined: Thu Sep 04, 2003 7:45 pm
Location: Germany

Post by DarkWood_Neo »

yes it's possible.

ICursorControl *ctrl = device->getCursorControl();

position2d<s32> cpos = ctrl->getPosition(); or
position2d<f32> cpos = ctrl->getRelativePosition();

the you got the position of the cursor and it's stored in cpos.
if you use "getRelativePosition()":
Returns the current position of the cursor. The returned position is a value between (0.0f, 0.0f) and (1.0f, 1.0f), where (0.0f, 0.0f) is the top left corner and (1.0f, 1.0f) is the bottom right corner of the render window.
and "getPosition()":
Returns the current position of the cursor. The returned position is the position of the mouse cursor in pixel units.
and this is the code to test if a mouse button is klicked:

Code: Select all

bool YourClass:OnEvent(SEvent event)
{
if (event.EventType == EET_MOUSE_INPUT_EVENT &&
		event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
	{
		//Your Code here
	};
return false;
};
btw: Reading the documentation is mostly advisable............
Post Reply