EventReceiver: Strange Mouse-Problem

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
Lo_Ord
Posts: 12
Joined: Thu Apr 27, 2006 2:24 pm

EventReceiver: Strange Mouse-Problem

Post by Lo_Ord »

Hi!

I'm trying to program a small Level-Editor for a game, and I'm stuck right now with a small problem.

I've implimented an "own" camera ("Own" because it's pretty much the Maya-Cam from Irrlicht)

The important section for me is the following:

Code: Select all

bool CameraEditorSceneNode::OnEvent(SEvent event)
{
	if (event.EventType = irr::EET_MOUSE_INPUT_EVENT)
	{
		switch(event.MouseInput.Event)
		{
			case EMIE_LMOUSE_PRESSED_DOWN:
				MouseKeys[0] = true;
				break;
		        case EMIE_LMOUSE_LEFT_UP:
				MouseKeys[0] = false;
				break;
		}
	return false;
	}
}
That's the part that I thought it might be useful, so I copied it into my Eventreceiver, it just controlls if the MouseButton is pressed. If so, the variable "selected" is set to "true", elso to false:

Code: Select all

bool IrrlichtManager::OnEvent(irr::SEvent event)
{
	if (event.EventType = irr::EET_MOUSE_INPUT_EVENT)
	{
		switch(event.MouseInput.Event)
		{
		case(irr::EMIE_LMOUSE_PRESSED_DOWN):
			this->selected = true;
			break;
		case(irr::EMIE_LMOUSE_LEFT_UP):
			this->selected = false;
			break;
		}	
		
	}
	return false;
};
So far, so good, but there's one small problem:
The whole thing works fine in the Camera-Scenenode (else the camera wouldn't work at all ^^), but when it comes to my EventReceiver, something strange happens: When I press the Mouse-button, the varible is set to true, but when I release it, nothing happens! I controlled it in Debug-Mode, the programm never ever reachtes the second Case-Statement, and i just can't see any reason why! Is the "Left-Up" - Event somehow swallowed by the camera's OnEvent?

TiA

Lo_Ord
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Not that this answers your problem, but I've never seen parantheses around the case clause, maybe compiler is treating that weirdly?

Oh, and also, don;t you want to return true, to consume the event?
Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

There's an assignment instead of a comparison used in the OnEvent. This definitely gives wrong results.
Post Reply