Button Click behavior persists through DragandDrop Manipulator
AnsweredAdd a press status to a button and use the addInputManipulator in a plugin. When the button is long pressed, the press status cannot persist and will switch to the previous status because a leave event is received. (press does not lift).
Add a press status to a button without using the addInputManipulator from a plugin. When the button is pressed for a long time, the press status can persist, and unless lifted and pressed, no leave event should occur.
info:generic> Enter
info:generic> Down
info:generic> Leave
info:generic> Cancel
-
The behavior is expected by design.
The behavior seen in the log is correct. Although it seems you are trying to implement a DragandDropManipulator.At first, the button pressed event is triggered but when the drag and drop kicks in, the previous button click is canceled which results in the the log sequence you see:
info:generic> Enter
info:generic> Down
info:generic> Leave
info:generic> CancelIt is not possible to have two manipulators executing at the same time. You would need to dispatch custom messages from the plugin side after handling DragandDropManipulator messages and then listen for those on the node that needs to change behaviors.
- Add Drag and Drop Manipulator
- Listen for Drag and Drop Manipulator messages on plugin and dispatch custom messages
- Listen for custom messages on the node where you want to handle behaviour
In order to resolve this issue, you can dispatch the down message in the next frame by submitting a task:
auto source = messageArguments.getSource();
getDomain()->getTaskDispatcher()->submit([source, this]() {
Button2D::ButtonConcept::PressedMessageArguments args;
args.setSource(source.get());
args.setHandled(false);
args.setType(Button2D::ButtonConcept::PressedMessage);
getMessageDispatcher()->dispatchMessage(&args, source.get());
});This will change the events from:
- Button down
- Drag start
- Dispatch button down
- Button events canceled
to:
- Button down
- Drag start
- Button events canceled
- Dispatch button down
0
Please sign in to leave a comment.
Comments
1 comment