Skip to main content

Button Click behavior persists through DragandDrop Manipulator

Answered

Comments

1 comment

  • Jason Stanczyk

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

     

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