[haiku-development] Re: [Question] Drag and drop - cancelling active drag/drop session

  • From: John Scipione <jscipione@xxxxxxxxx>
  • To: "haiku-development@xxxxxxxxxxxxx" <haiku-development@xxxxxxxxxxxxx>
  • Date: Tue, 17 Jul 2018 16:20:49 -0700

On Mon, Jul 16, 2018 at 12:59 PM, Zenja Solaja <solaja@xxxxxxxxx> wrote:

I'm working on a native video editor for Haiku, and have a question
regarding how to cancel an active drag-drop session.  From the users point
of view, they can drag any clip either horizontally or vertically.  Simple
repositioning of clips is handled without drag/drop, but eventually the
software figures out a complex move is requested and transitions to a
drag/drop mode.  I'm using the simple Drag'n'Drop protocol via calling
DragMessage(msg, rect).  Until the mouse button is released, the system
draws a rectangle indicating potential drop position.

The problem I have is that I need to cater for the user cancelling a complex
move operation, ie. they revert back to a simple repositioning mode.  I'd
like to cancel the current DragMessage session, or alternatively, I'd like
to remove the visible rectangle drawn by the system.  Note - the mouse
button is still down.

Does anyone know how to cancel an active drag session before MouseUp()?

If this is not possible, then I'd have to implement my own 'drag/drop'
mechanism and bypass the system one (I'd rather not do that).

Look for the user to push the esc key in KeyDown while they are in a
drag operation, and if they do, set a flag to cancel the drop and do
whatever else you need to do (erase the helper d&d rectangle). Then on
MouseUp read the flag in and ignore the dropped message. You may need
to adjust the even mask with BView::SetEventMask() in order to catch
the KeyDown message.

Other related posts: