Skip to content

Commit

Permalink
Merge 757b820 into 267d7f3
Browse files Browse the repository at this point in the history
  • Loading branch information
corranwebster committed Aug 22, 2014
2 parents 267d7f3 + 757b820 commit 0a58448
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions enable/tools/drop_tool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#------------------------------------------------------------------------------
# Copyright (c) 2014, Enthought, Inc.
# All rights reserved.
#
# This software is provided without warranty under the terms of the BSD
# license included in LICENSE.txt and may be redistributed only
# under the conditions described in the aforementioned license. The license
# is also available online at http://www.enthought.com/licenses/BSD.txt
# Thanks for using Enthought open source!
#------------------------------------------------------------------------------
""" Abstract base class for tools that handle drag and drop """

from __future__ import absolute_import, print_function, division

from enable.base_tool import BaseTool


class BaseDropTool(BaseTool):
""" Abstract base class for tools that handle drag and drop """

def normal_drag_over(self, event):
""" Handle dragging over the component """
try:
result = self.accepts_drop(event.obj)
self.component.window.set_drag_result(result)
except Exception:
self.component.window.set_drag_result("error")
raise

def normal_dropped_on(self, event):
if self.accepts_drop(event.obj) != "none":
self.handle_drop(event.obj)

def accepts_drop(self, urls):
""" Whether or not to accept the drag, and the type of drag
The return value is either "none", if the drag is refused for the
dragged object types, or one of "copy", "move", or "link".
Subclasses should override this method.
"""
raise NotImplementedError

def handle_drop(self, urls):
""" Handle objects being dropped on the component
Subclasses should override this method.
"""
raise NotImplementedError

0 comments on commit 0a58448

Please sign in to comment.