Lemur: mouse event consumed, but.. not?

I created a Button with a Command.
So Command.execute() is called at PickEventSession.buttonEvent() at

tempCapture.getControl(MouseEventControl.class).mouseButtonEvent(event2, hitTarget, tempCapture);

and it is consumed, but it does not promptly returns and calls this also:

tempCapture.getControl(CursorEventControl.class).cursorButtonEvent(event1, hitTarget, tempCapture);

I wonder if it is intentional, like delivering simultaneously to similar listeners (mouse and cursor)?
Otherwise would it be missing if( consumed ) return true; at this line?

See the comment just below that:

        // It's kind of a bug but when delivering to a single MouseEventControl, the
        // 'consumed' state is ignored.  To emulate the behavior of both of these listener
        // sets being together, I'll ignore the consumed flag here also.
        // Where this comes up is in the slider thumb where previously the button click
        // listener and the dragger were part of the same MouseEventControl and thus the
        // drag still saw the mouse button events even though the Button itself is consuming
        // them first.
        // In reality, we probably want some way to add the drag listener to the beginning
        // of the list.

Within a single MouseEventControl you will get the event event to all of those listeners even if the first listener in that control consumes it. Sometimes this is desirable else I will have to add a bunch of listener order management stuff.

So, if we agree to that, then it is also necessary to deliver to the cursor control also because within one spatial I needed to maintain that idea because in general mouse and cursor listeners should be interchangeable from a ‘who gets the event’ perspective.

I hope that makes sense. :slight_smile:

1 Like

I was looking for that explanation everywhere (class comment, method comment…) least “after” :slight_smile:

When the button was clicked and performed its action, my other listener got the event and that made me quite puzzled. I was generating an exception like some element had not been considered (like if I skipped coding something). Now I just generate a warning.

Basically this let us process the button click in two different places, but how to know it was consumed by a MouseButtonEvent during a CursorButtonEvent, so we can properly skip it in the 2nd if we want? The Command.execute() only gives access to the Button object.

One way I thought was count the frames and store at the Button an user object saying what was the last frame when it’s action was processed.

Obs.: at the CursorButtonEvent is where I detect what button was pressed to determine what action to take (this let me implement double (or more) clicks.

Anyway, I just removed the code from CursorButtonEvent flow, and let it alone at Command.execute(). So it is working now :).

Well, when you have actually listeners then you can see if the event has been consumed already and choose what to do based on that.