Mouse button press event injection...working well...but...

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

SalvoFa
Not too shy to talk
Not too shy to talk
Posts: 29
Joined: Mon Feb 25, 2008 15:25
Location: Italy

Mouse button press event injection...working well...but...

Postby SalvoFa » Fri Jun 20, 2008 07:30

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.

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Fri Jun 20, 2008 10:02

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.
Check out my released snake game using Cegui!

SalvoFa
Not too shy to talk
Not too shy to talk
Posts: 29
Joined: Mon Feb 25, 2008 15:25
Location: Italy

Postby SalvoFa » Tue Jun 24, 2008 09:15

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...

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Jun 24, 2008 18:08

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.

SalvoFa
Not too shy to talk
Not too shy to talk
Posts: 29
Joined: Mon Feb 25, 2008 15:25
Location: Italy

Postby SalvoFa » Tue Jul 01, 2008 14:50

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?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Jul 01, 2008 18:40

Are you injecting the key up events via System::injectKeyUp?

SalvoFa
Not too shy to talk
Not too shy to talk
Posts: 29
Joined: Mon Feb 25, 2008 15:25
Location: Italy

Postby SalvoFa » Wed Jul 02, 2008 08:46

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?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Wed Jul 02, 2008 11:33

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.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 10 guests