This repository was archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathdragDrop.lcdoc
More file actions
79 lines (57 loc) · 2.59 KB
/
dragDrop.lcdoc
File metadata and controls
79 lines (57 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Name: dragDrop
Type: message
Syntax: dragDrop
Summary:
Sent to the <object(glossary)> where data was dropped when a
<drag and drop> finishes.
Introduced: 2.0
Associations: card, field, button, graphic, scrollbar, player, image
OS: mac, windows, linux
Platforms: desktop, server
Example:
on dragDrop -- check whether a file is being dropped
if the dragData["files"] is empty then beep 2
pass dragDrop
end dragDrop
Description:
Handle the <dragDrop> <message> to perform an action when the user drops
data, or <trap> the <message> to prevent text from being dropped.
The <dragDrop> <message> is sent to the <control> where data is being
dragged.
>*Important:* If the <acceptDrop> <property> is set to false at the
> time the drop occurs, no <dragDrop> <message> is sent.
LiveCode automatically handles the mechanics of dragging and dropping
text between and within unlocked fields. To support this type of drag
and drop operation, you don't need to do any scripting: the text is
dropped into the field automatically when LiveCode receives the
<dragDrop> <message>.
To prevent an unlocked field from accepting a drag and drop, trap the
<dragDrop> <message>. If you don't want to allow a particular
<field(keyword)> to accept text drops, place a <dragDrop> <handler> in
the field that does not contain a <pass> <control structure>:
on dragDrop -- in script of field or one of its owners
-- do nothing, but trap the message
end dragDrop
On the other hand, if you want to perform some action when text is
dropped into an unlocked field, you need to pass the <dragDrop>
<message> once you're done with it in order to allow the drop to
take place:
on dragDrop
set the cursor to 9023
pass dragDrop -- needed for drop to occur
end dragDrop
To accept drops to a locked field or a control other than a field,
handle the <dragDrop> message, using the <dragData> <property> to
determine what data is being dragged. For these objects, your <dragDrop>
<handler> must get the dragged data and put it into the
<object(glossary)> (or perform whatever action you want to do on a
drop); the behavior is not automated as it is for <unlock|unlocked>
<field(object)|fields>.
References: pass (control structure), dropChunk (function),
dragSource (function), object (glossary), property (glossary),
handler (glossary), message (glossary), unlock (glossary),
control structure (glossary), drag and drop (glossary),
control (glossary), trap (glossary), field (keyword), dragEnd (message),
field (object), dragData (property), acceptDrop (property),
dragImageOffset (property), dragAction (property)
Tags: ui