Places:Drag & Drop: Difference between revisions

Jump to navigation Jump to search
No edit summary
Line 4: Line 4:
== Toolbar Drag & Drop Handling ==
== Toolbar Drag & Drop Handling ==


Toolbar handles drag & drop on its contained toolbarbuttons, drag&drop on menupopups attached to menu types buttons is handled by their own handlers.
Toolbar handles drag&drop on its contained toolbarbuttons, while drag&drop on sub-menupopups (attached to menu type toolbarbuttons) is handled by their own handlers.


on <code>dragstart</code> event we special handle containers, we want to drag them only if the gesture is not toward down, since in such a case a container should open to allow for "click, down, release" behavior.
On <code>dragstart</code> event we special handle containers, we want to drag them only if the gesture is not toward down, since in such a case a container should open to allow for "click, down, release" behavior.
Then we cache the current dragged Places node and activate the controller with a focus event, that's needed to ensure controller is active for the correct view and ready to catch our data.
Then we cache the current dragged Places node and activate the controller with a focus event, that's needed to ensure controller is active for the correct view and ready to catch our data.


Then we call the controller's <code>setDataTransfer</code> method that executes the following tasks:
Then we call the controller's <code>setDataTransfer</code> method that executes the following tasks:
# Extracts current DataTransfer object from the event.
# Extracts current <code>DataTransfer</code> object from the event.
# Null the current viewer, this way we won't rebuild the view while wrapping nodes
# Null the current viewer, this way we won't rebuild the view while wrapping nodes.
# Add the Places node to dragged items, using correct flavor for every node's type.
# Add the Places node to dragged items, using correct flavor for every node's type.
# restore the viewer
# restore the viewer.


While moving over the toolbar within a drag session, the <code>dragover</code> event will wnsure the drop indicator bar is correctly positioned, and will automatically open the menu toolbarbuttons when we drag over them. We use <code>PlacesControllerDragHelper.canDrop</code> and the local _getDropPoint helper to ensure we can drop at a certain insertionPoint.
While moving over the toolbar within a drag session, the <code>dragover</code> event will ensure the drop indicator bar is correctly positioned, and will automatically open the menu type toolbarbuttons when we drag over them.
The <code>dragleave</code> event works in a similar way, hiding the indicator bar and setting timers to close menu toolbarbuttons when we are not dragging anymore upon them.
We use <code>PlacesControllerDragHelper.canDrop</code> and the local <code>_getDropPoint</code> helper to ensure we can drop at a valid insertionPoint.
The <code>dragleave</code> event works in a similar way, hiding the indicator bar and setting timers to close menu type toolbarbuttons when we are not anymore dragging over them.


Finally <code>drop</code> event takes care of checking  
Finally <code>drop</code> event takes care of checking we have a valid drop point, and calls the controller drop helper.


== Menu Drag & Drop Handling ==
== Menu Drag & Drop Handling ==
Confirmed users
595

edits

Navigation menu