1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 from pyjamas import DOM
16 from pyjamas.ui import Event
17
18 DROP_EVENTS = [ "dragenter", "dragover", "dragleave", "drop"]
19
21 etype = DOM.eventGetType(event)
22 if etype == "dragenter":
23 for listener in listeners:
24 listener.onDragEnter(event)
25 return True
26 elif etype == "dragover":
27 for listener in listeners:
28 listener.onDragOver(event)
29 return True
30 elif etype == "dragleave":
31 for listener in listeners:
32 listener.onDragLeave(event)
33 return True
34 elif etype == "drop":
35 for listener in listeners:
36 listener.onDrop(event)
37 return True
38 return False
39
40
42
46
52
54 self._dropListeners.append(listener)
55
57 self._dropListeners.remove(listener)
58
60 """
61 Decide whether to accept the drop.
62
63 You may inspect the event's dataTransfer member.
64
65 You may get the types using pyjamas.dnd.getTypes(event).
66
67 This event is used to determine whether the drop target may
68 accept the drop. If the drop is to be accepted, then this event has
69 to be canceled using DOM.eventPreventDefault(event).
70 """
71 pass
72
74 """
75 This event determines what feedback is to be shown to the user. If
76 the event is canceled, then the feedback (typically the cursor) is
77 updated based on the dropEffect attribute's value, as set by the event
78 handler; otherwise, the default behavior (typically to do nothing)
79 is used instead.
80
81 Setting event.dataTransfer.dropEffect may affect dropping behavior.
82
83 Cancel this event with DOM.eventPreventDefault(event) if you want the
84 drop to succeed.
85
86 """
87 pass
88
90 """
91 This event happens when the mouse leaves the target element.
92 """
93 pass
94
96 """allows the actual drop to be performed. This event also needs to be
97 canceled, so that the dropEffect attribute's value can be used by the
98 source (otherwise it's reset).
99 """
100 pass
101