Page 1 of 1
Mouse button press event injection...working well...but...
Posted: Fri Jun 20, 2008 07:30
by SalvoFa
Hi all!
I'm using this piece of code to inject mouse left button press in my CEGUI widget:
Code: Select all
curr_button_ref = ref->recursiveChildSearch(mt_curr_btn_name);
CEGUI::Rect r = curr_button_ref->getPixelRect();
CEGUI::System::getSingleton().injectMousePosition(r.d_left, r.d_top);
CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);
CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);
It works well but I can't see the button animation (pressed and released)...I suppose that there must be a sort of timer to handle the down and up event in a good way...how can I solve this problem?
Thanks.
Posted: Fri Jun 20, 2008 10:02
by scriptkid
Hi,
you don't see the animation because there is no repaint between the input events. So on the next 'renderGUI' CEGUI will show the last state. I am not sure what you are trying to do, but you should only inject input when it happens. Now you send both mouseDown and Up, which cannot happen at the same time ('mouse wise'
) Or do you want to simulate input, because of an automatic test or something? If that's the case, you should add some states to you while loop, such as "SendingMouseDown", "Pause", "SendingMouseUp", while rendering CEGUI each frame.
HTH.
Posted: Tue Jun 24, 2008 09:15
by SalvoFa
This seems quite difficult to implement...however I'm developing a custom spatial navigation using the keyboard instead of the mouse...so I need to simulate the mouse button press when I'm over a button and I press enter with the keyboard...
Posted: Tue Jun 24, 2008 18:08
by CrazyEddie
You could always have the key down event for the enter key emulate left mouse button down and the key up event left mouse button up; this should give you the required delay (since the user is involved) and should allow the graphical state transitions to show.
CE.
Posted: Tue Jul 01, 2008 14:50
by SalvoFa
CrazyEddie wrote:You could always have the key down event for the enter key emulate left mouse button down and the key up event left mouse button up; this should give you the required delay (since the user is involved) and should allow the graphical state transitions to show.
CE.
Eddie...I've tried to do this but it seems that the EventKeyUp event is not recognized...I'm able to handle EventKeyDown but EventKeyUp seems that never arrives.
Very strange...any hint?
Posted: Tue Jul 01, 2008 18:40
by CrazyEddie
Are you injecting the key up events via System::injectKeyUp?
Posted: Wed Jul 02, 2008 08:46
by SalvoFa
No...I'm simply waiting for the event to arrive...
I thought that the keyup was sent by the system each time the user releases a key!
Am I wrong?
Posted: Wed Jul 02, 2008 11:33
by CrazyEddie
Yeah, this is what the issue will be then
CEGUI does not find out about any external events that you do not tell it about. You have to inject all raw source input events you need to react to. If you did not read it yet, please read
The Beginner Guide to Injecting Inputs.
HTH
CE.