CEGUI 0.6.2 v 0.7.5: Button letting fast clicks pass through

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Senzin
Just popping in
Just popping in
Posts: 8
Joined: Sat Apr 23, 2011 01:13

CEGUI 0.6.2 v 0.7.5: Button letting fast clicks pass through

Postby Senzin » Wed May 04, 2011 07:04

I'm using CEGUI with Ogre and for various reasons need my app to work on machines with version 0.6.2. I have a couple problems that are only happening in the 0.6.2 compile.

(1)
In my app I have code like this:

Code: Select all

bool control::mousePressed( const OIS::MouseEvent &evt, OIS::MouseButtonID id )
{
   if (CEGUI::System::getSingleton().injectMouseButtonDown(convertButton(id))) return true;

   // ... rest of the code ...

   mouseDown = true;

The way that works is if the user clicks on a Cegui window, Cegui will notice, do something (or not, depending on what part of the window they clicked on) and return true, indicating it handled the click, one way or another. When that happens, that if statement will evaluate true, thus making the code "return true" execute, leaving the mousePressed function. But if the user doesn't click on a Cegui window, then the "rest of the code" in mousePressed will execute.

What I'm finding, however, is that in Cegui 0.6.2 if I click on a button repeatedly, and a little fast, some of the clicks don't get handled by Cegui and go straight through. So even though I'm clicking on a Cegui button, that variable "mouseDown" will get set to true. (And I've subscribed to both MouseClick and MouseDoubleClick events.) What's more is that even though the mouse pressed event was not handled, the mouse released event always seems to get triggered. The mouse release function has a similar structure, where if Cegui handles the mouse release event, then it returns and the rest of the function doesn't execute.

So in this example, what can happen is a user rapidly clicks on a button, Cegui fails to handle the mouse press event, so the rest of the function executes and mouseDown gets set to true. However the mouse release event is handled, so mouseDown never gets set back to false. And bam, the mouse is now stuck down.

Yes, there are some workarounds that are currently in place, but they kinda break the rule I'm using that only one system will handle a particular event like a mouse click.

(2)
In CELE2, I made a frame with no title bar that just holds buttons. In 0.7.5, if I click on an empty space in that frame, like in between two buttons, the Cegeui injectMouseButtonDown still returns true, as it should (even though there is no subscribed event for clicking on the frame, I did still click on the frame, as opposed to somewhere in Ogre's 3D environment). In 0.6.2, however, it returns false, so using the example from above, even though I clicked on the frame, the rest of the code in the mousePressed function will be executed.

To make sure, in code I have explicitly set MousePassThroughEnabled to false. I even tried subscribing to mouse click events for when I click on the frame. And the events work! But the injectMouseButtonDown still returns false, causing the rest of the code in the mousePressed function to execute.

Now this problem doesn't happen with the buttons in this frame (aside from the problems described above in (1)). One difference between the buttons and the frame is this: I make the root sheet manually in code and then just attach the various windows I bring in from different .layout files. So when I created a new layout in CELE2 it asked if I wanted to start with an initial root window and I said no. Could that have something to do with it? Is there something about how I'm bringing these windows into Ogre that I'm doing wrong?

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: CEGUI 0.6.2 v 0.7.5: Button letting fast clicks pass thr

Postby Jamarr » Wed May 04, 2011 14:02

This sounds like a known issue in v0.6.2 with injecting-input and CEGUI not consuming the event. The problem is this: if a users clicks on a 1) inactive window, the window will become active and the input marked as consumed 2) active window, the input is not marked as consumed even though it should be. So basically, if the inject function returns false you have to follow that up with a secondary check to see if the active window was actually hit before allowing your game logic to process the input. This behavior was fixed in v0.7.x, although in this version need to explicitly enable MousePassThrough on the GUISheet. You can read about v0.6.2 bug here: viewtopic.php?p=16135#p16135
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!


Return to “Help”

Who is online

Users browsing this forum: No registered users and 9 guests