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.
Detect mouse click?
Catch mouse events instead of keyboard ones. Also see SEvent.MouseInput
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?
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!
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!
Check example4.
In class MyEventReceiver, OnEvent function, you can add another if statement to check whether the event is an EET_MOUSE_INPUT_EVENT.
In class MyEventReceiver, OnEvent function, you can add another if statement to check whether the event is an EET_MOUSE_INPUT_EVENT.
Aung Sithu
*** Check out my latest book, Beginner's guide to Irrlicht 3D engine: http://bit.ly/rSnm4O
Company: http://rivaledge.sg
*** Check out my latest book, Beginner's guide to Irrlicht 3D engine: http://bit.ly/rSnm4O
Company: http://rivaledge.sg
What if my handler is in a different file?
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
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!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);
}
...
}
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way