Skip to content

Commit 39e032f

Browse files
bhall2001montegoulding
authored andcommitted
Expanded examples
- Expanded dispatch command examples (not sure why this did not go with last commit) (cherry picked from commit 755fcfb)
1 parent 7194a4e commit 39e032f

1 file changed

Lines changed: 31 additions & 3 deletions

File tree

docs/dictionary/command/dispatch.lcdoc

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ Name: dispatch
22

33
Type: command
44

5-
Syntax: dispatch <message> [ to <target> ][ with {<argumentList>, | arrayName} ]
65
Syntax: dispatch <message> [ to <target> ][ with <argumentList> ]
76

87
Summary:
@@ -18,9 +17,36 @@ Example:
1817
dispatch "updateWidget"
1918

2019
Example:
21-
dispatch "setList" with myVar1, myVar2
20+
on mouseUp
21+
local tWidth, tHeight
22+
23+
put 200 into tWidth
24+
put 100 into tHeight
25+
dispatch "setSize" with tWidth, tHeight
26+
end mouseUp
27+
28+
on setSize pWidth, pHeight
29+
set the width of graphic "myRectangle" to pWidth
30+
set the height of graphic "myRectangle" to pHeight
31+
end setSize
2232

2333
Example:
34+
# An example of using an array as an argument
35+
36+
on mouseUp
37+
local tDataArray
38+
39+
put "Mickey" into tDataArray["firstName"]
40+
put "Mouse" into tDataArray["lastName"]
41+
42+
dispatch "updateUI" to card "myCard" with "Hello World", tDataArray
43+
end mouseUp
44+
45+
on updateUI pTitle, @pArray
46+
put pTitle into field "Title"
47+
put pArray["firstName"] into field "First Name"
48+
put pArray["lastName"] into field "Last Name"
49+
end updateUI
2450

2551
Parameters:
2652
message:
@@ -31,7 +57,7 @@ A reference to any LiveCode object.
3157

3258
argumentList:
3359
A comma separated list of expressions containing the arguments to send.
34-
60+
Arrays are expressions and are valid to send as arguments.
3561

3662
It (enum):
3763
Set by <dispatch> to indicate how the message was processed.
@@ -50,6 +76,8 @@ as it allows a <behavior> script to send an 'event' to one of its child
5076
objects and then perform an action depending on the outcome.
5177

5278
Executing a <dispatch> command causes the <message> to be sent to the
79+
target object with the given argument list. This message passes through
80+
the message path in the normal way.
5381

5482
If no <target> is specified, the <message> is sent to ' <me> '. In the
5583
context of a <behavior>, this is typically the child that is executing

0 commit comments

Comments
 (0)