Lines Matching +full:- +full:- +full:target
1 """Drag-and-drop support for Tkinter.
6 I am trying to make this as generic as possible -- not dependent on
11 for it that starts the drag-and-drop process. Typically, you should
16 instantiation, the returned instance should not be stored -- it will
17 be kept alive automatically for the duration of the drag-and-drop.
19 When a drag-and-drop is already in process for the Tk interpreter, the
24 The object is *not* necessarily a widget -- it can be any
25 application-specific object that is meaningful to potential
26 drag-and-drop targets.
28 Potential drag-and-drop targets are discovered as follows. Whenever
29 the mouse moves, and at the start and end of a drag-and-drop move, the
30 Tk widget directly under the mouse is inspected. This is the target
31 widget (not to be confused with the target object, yet to be
32 determined). If there is no target widget, there is no dnd target
33 object. If there is a target widget, and it has an attribute
39 function returns something other than None, this is the new dnd target
40 object. If dnd_accept() returns None, or if the target widget has no
41 dnd_accept attribute, the target widget's parent is considered as the
42 target widget, and the search for a target object is repeated from
44 root widget. If none of the target widgets can produce a target
45 object, there is no target object (the target object is None).
47 The target object thus produced, if any, is called the new target
48 object. It is compared with the old target object (or None, if there
49 was no old target widget). There are several cases ('source' is the
52 - Both the old and new target objects are None. Nothing happens.
54 - The old and new target objects are the same object. Its method
57 - The old target object was None, and the new target object is not
58 None. The new target object's method dnd_enter(source, event) is
61 - The new target object is None, and the old target object is not
62 None. The old target object's method dnd_leave(source, event) is
65 - The old and new target objects differ and neither is None. The old
66 target object's method dnd_leave(source, event), and then the new
67 target object's method dnd_enter(source, event) is called.
69 Once this is done, the new target object replaces the old one, and the
74 The drag-and-drop processes can end in two ways: a final target object
75 is selected, or no final target object is selected. When a final
76 target object is selected, it will always have been notified of the
80 dnd_enter(). The target is notified of the drop by a call to its
83 If no final target object is selected, and there was an old target
87 Finally, the source object is notified that the drag-and-drop process
88 is over, by a call to source.dnd_end(target, event), specifying either
89 the selected target object, or None if no target object was selected.
91 sometimes simpler than to do it in the target's dnd_commit(). The
92 target's dnd_commit() method could then simply be aliased to
97 dnd_start(). This will call dnd_leave() if a target is currently
134 self.target = None
137 self.release_pattern = "<B%d-ButtonRelease-%d>" % (button, button)
167 old_target = self.target
173 self.target = None
177 self.target = new_target
186 target = self.target
195 self.target = self.source = self.initial_widget = self.root = None
196 if target is not None:
198 target.dnd_commit(source, event)
200 target.dnd_leave(source, event)
202 source.dnd_end(target, event)
205 # ----------------------------------------------------------------------
260 x = event.x_root - x_org
261 y = event.y_root - y_org
263 return x - self.x_off, y - self.y_off
265 def dnd_end(self, target, event): argument
284 dx, dy = x2-x1, y2-y1
291 self.canvas.move(self.dndid, x-x1, y-y1)