Page 1 of 1

Detect mouse click?

Posted: Tue Oct 21, 2008 5:41 am
by fennec
How do I detect if a mouse button is clicked?

I'm using a copy-pasted event receiver from the Movement example project.

I see that the keycodes list includes KEY_LBUTTON and KEY_RBUTTON, but they don't seem to be what I'm looking for. Nor does CursorControl have anything about buttons.

Thx a bunch.

Posted: Tue Oct 21, 2008 6:51 am
by bitplane
Catch mouse events instead of keyboard ones. Also see SEvent.MouseInput

Posted: Wed Oct 22, 2008 3:52 pm
by arras

Code: Select all

if(event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) do whatever;

What if you're using a separate file to handle your events?

Posted: Thu Oct 23, 2008 3:17 am
by knicholes
I'm trying to capture a mouse click and just have it change the text in the Hello World example. I can't put the code in the event handler because it doesn't know what the guienv object is, so I tried to put the code in main, but I don't know how to check for it from main--

while(device->run())
{
if(event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
{
guienv->addStaticText(L"Hello World! Event Recognition Complete!",
rect<int>(10,10,200,202), true);
}
...
}

This doesn't know what event is. I saw some guy do something with an array of keys, but I just don't get it. Please help!

Posted: Thu Oct 23, 2008 5:24 am
by aungsithu
Check example4.
In class MyEventReceiver, OnEvent function, you can add another if statement to check whether the event is an EET_MOUSE_INPUT_EVENT.

What if my handler is in a different file?

Posted: Thu Oct 23, 2008 4:05 pm
by knicholes
In example 4, it shows how to handle the event by modifying the OnEvent() function that is in the SAME FILE as the main() function. It just modifies "node"'s position. If the OnEvent overridden call is in a different file, it won't know what "node" is. I'm wondering how you could accomplish this with two files, with the handler functions being separate from the main function.

Re: What if you're using a separate file to handle your even

Posted: Thu Oct 23, 2008 4:17 pm
by JP
knicholes wrote: while(device->run())
{
if(event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
{
guienv->addStaticText(L"Hello World! Event Recognition Complete!",
rect<int>(10,10,200,202), true);
}
...
}
this is a really bad thing to do and shows you don't know how to code yet, i would suggest learning C++ first before jumping into 3D graphics... I don't mean to offend you, it's for the best!

Posted: Thu Oct 23, 2008 5:15 pm
by rogerborg