Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit abd9401

Browse files
committed
[Interactive Tutorial] Edits for the To Do List tutorial
1 parent 7a3d2d6 commit abd9401

7 files changed

Lines changed: 75 additions & 60 deletions

File tree

-15.2 KB
Loading
-11.5 KB
Loading
-11.5 KB
Loading
-12.5 KB
Loading
3.69 KB
Loading
6.33 KB
Loading

Toolset/palettes/tutorial/courses/First Run/tutorials/To Do List/lessons/App Lesson.txt

Lines changed: 75 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tutorial "FM Plugin"
1+
tutorial "To Do List"
22

33
prologue
44
In this tutorial we will create a simple To Do List.
@@ -76,11 +76,11 @@ step "Properties interlude"
7676
The Property Inspector is a window that allows you to control these properties.
7777
action
7878
interlude
79-
go to step "Set Stack Properties"
79+
go to step "Set Stack Properties"
8080
end step
8181

8282
step "Set Stack Properties"
83-
Click on the Inspector icon on the toolbar to open the Property
83+
Click on the Inspector icon on the Toolbar to open the Property
8484
Inspector.
8585
action
8686
highlight toolbar "Inspector"
@@ -90,7 +90,7 @@ end step
9090

9191
step "Property Inspector Interlude"
9292
Properties of objects are grouped into sections. You can hover over
93-
the icons at the top of the inspector to see what each section is
93+
the icons at the top of the Property Inspector to see what each section is
9494
called.
9595
action
9696
interlude
@@ -104,7 +104,7 @@ step "Set Stack Title"
104104
The first property we will set is the 'Title' of the stack. You will see the
105105
title of the stack change after you set the property.
106106

107-
Set the 'Title' of the stack to "To Do List".
107+
Set the 'Title' of the stack to "To Do List" and press Enter.
108108
action
109109
highlight property "title" of section "basic"
110110
wait until the title of stack "Mainstack" is "To Do List"
@@ -130,7 +130,7 @@ step "Create Add Icon"
130130
The first object we will add is an 'add' icon. The user will click on this to
131131
add a new item to the list.
132132

133-
Drag an SVG Icon from the tools palette onto your stack.
133+
Drag an SVG Icon from the Tools Palette onto your stack.
134134
action
135135
highlight tool "Create com.livecode.widget.svgpath"
136136
capture the next new widget of stack "Mainstack" as "add"
@@ -139,7 +139,7 @@ action
139139
end step
140140

141141
step "Set Add Location"
142-
Position the icon, as shown.
142+
Resize and position the icon, as shown.
143143
action
144144
add guide "addLoc" with rect "280,10,310,40" to stack "Mainstack"
145145
highlight guide "addLoc"
@@ -150,7 +150,7 @@ end step
150150
step "Open Property Inspector"
151151
Next we need to set some properties of the icon.
152152

153-
Click on the toolbar icon to open the Property Inspector for the
153+
Click on the Inspector icon in the Toolbar to open the Property Inspector for the
154154
icon.
155155
action
156156
highlight toolbar "Inspector"
@@ -159,11 +159,11 @@ action
159159
end step
160160

161161
step "Set add name"
162+
Set the name property of the SVG Icon to "Add" and press Enter.
163+
162164
The 'Name' property is used when we refer to an object in the code. We want to
163165
use short, unique, descriptive names to make it easier when we start writing
164166
code.
165-
166-
Set the name property of the SVG Icon to "Add".
167167
action
168168
highlight property "name" of section "Basic"
169169
wait until the name of widget "add" is "Add"
@@ -176,7 +176,7 @@ step "Set add icon"
176176

177177
Click on the 'Preset' property where it shows a star. This will pop up a
178178
set of icons for you to choose from. Choose the plus icon, its name in the
179-
list is 'plus'.
179+
list is 'plus'. You might need to scroll the list of icons to find the one you want.
180180
action
181181
highlight property "iconPresetName" of section "Basic"
182182
wait until the iconPresetName of widget "add" is "plus"
@@ -187,6 +187,8 @@ skip point
187187

188188
step "Create task list"
189189
Next we want to add a list field. This will be used to display the list of tasks.
190+
191+
Drag a list field from the Tools Palette onto your stack.
190192
action
191193
highlight tool "Create list field"
192194
capture the next new field of stack "Mainstack" as "TaskList"
@@ -195,7 +197,7 @@ action
195197
end step
196198

197199
step "Set task list Location"
198-
Position the field, as shown.
200+
Resize and position the field, as shown.
199201
action
200202
add guide "taskListLoc" with rect "0,60,320,568" to stack "Mainstack"
201203
highlight guide "taskListLoc"
@@ -206,7 +208,7 @@ end step
206208
step "Task List PI"
207209
As before we need to set some properties of the field.
208210

209-
Click on the toolbar icon to open the property inspector for the
211+
Click on the Inspector icon in the Toolbar to open the Property Inspector for the
210212
field.
211213
action
212214
highlight toolbar "Inspector"
@@ -215,10 +217,10 @@ action
215217
end step
216218

217219
step "Set task list name"
218-
As before we want to give the field a short descriptive name, to make things
220+
Again, we want to give the field a short descriptive name to make things
219221
easier when we write code.
220222

221-
Set the name of the field to "TaskList".
223+
Set the name of the field to "TaskList" and press Enter.
222224
action
223225
highlight property "name" of section "Basic"
224226
wait until the name of field "taskList" is "TaskList"
@@ -229,7 +231,7 @@ skip point
229231

230232
step "Set task list contents"
231233
We want the task list to start off empty. Delete the default contents from
232-
the field.
234+
the field and click away to allow the change to take effect.
233235
action
234236
highlight property "styledText" of section "contents"
235237
wait until the text of field "taskList" is ""
@@ -266,15 +268,6 @@ step "Script Editor Interlude"
266268
The Script Editor is a window that allows you to add code to the
267269
objects on your stack.
268270

269-
Some objects have a default script associated with then when you first open
270-
the Script Editor.
271-
action
272-
interlude
273-
highlight script editor for widget "add"
274-
go to step "Script Editor Apply"
275-
end step
276-
277-
step "Script Editor Apply"
278271
The code you have added in the Script Editor does not become live
279272
until you click on the 'Apply' button. When this is clicked, you will
280273
get feedback about whether the code you have written has any
@@ -300,8 +293,17 @@ step "mouseUp message"
300293
Don't forget to click the 'Apply' button when you have finished.
301294
script
302295
on mouseUp
296+
local tList
297+
303298
ask "Please enter a task"
304-
put it & return after field "taskList"
299+
300+
put the text of field "TaskList" into tList
301+
if field "TaskList" is empty then
302+
put it into tList
303+
else
304+
put return & it after tList
305+
end if
306+
set the text of field "TaskList" to tList
305307
end mouseUp
306308
action
307309
highlight script editor for widget "add"
@@ -359,14 +361,11 @@ end step
359361
skip point
360362

361363
step "Add task"
362-
Click the 'Add' icon and enter "Buy milk" as a task, it will appear at the
364+
Click the 'Add' icon and enter the task "Buy milk", it will appear at the
363365
bottom of the list.
364-
value
365-
Buy milk
366-
367366
action
368367
highlight widget "add"
369-
wait until the text of field "taskList" is value
368+
wait until the text of field "taskList" is "Buy milk"
370369
go to step "Return to Edit Mode"
371370
end step
372371

@@ -392,7 +391,7 @@ action
392391
end step
393392

394393
step "Create delete Icon"
395-
To create the 'Delete' icon drag another SVG Icon from the tools palette onto your stack.
394+
To create the 'Delete' icon drag another SVG Icon from the Tools Palette onto your stack.
396395
action
397396
highlight tool "Create com.livecode.widget.svgpath"
398397
capture the next new widget of stack "Mainstack" as "delete"
@@ -401,7 +400,7 @@ action
401400
end step
402401

403402
step "Set Delete Location"
404-
Position the icon, as shown.
403+
Resize and position the icon, as shown.
405404
action
406405
add guide "deleteLoc" with rect "240,10,270,40" to stack "Mainstack"
407406
highlight guide "deleteLoc"
@@ -412,7 +411,7 @@ end step
412411
step "Open Delete Property Inspector"
413412
Next we need to set the properties of the 'Delete' icon.
414413

415-
Click on the toolbar icon to open the Property Inspector for the
414+
Click on the Inspector icon on the Toolbar to open the Property Inspector for the
416415
SVG icon.
417416
action
418417
highlight toolbar "Inspector"
@@ -421,7 +420,7 @@ action
421420
end step
422421

423422
step "Set delete name"
424-
Set the name property of the SVG Icon to "Delete".
423+
Set the name property of the SVG Icon to "Delete" and press Enter.
425424
action
426425
highlight property "name" of section "Basic"
427426
wait until the name of widget "delete" is "Delete"
@@ -440,7 +439,7 @@ action
440439
end step
441440

442441
step "Open Delete Script"
443-
Select the 'Delete' icon then click the Code button in the Toolbar.
442+
Select the 'Delete' icon then click the Code icon in the Toolbar to open the Script Editor for the icon.
444443
action
445444
highlight toolbar "Code"
446445
wait until there is a script editor for widget "delete"
@@ -457,9 +456,13 @@ step "Delete mouseUp"
457456
Don't forget to click the 'Apply' button when you have added the code.
458457
script
459458
on mouseUp
459+
local tList
460+
460461
answer "Do you want to delete this task?" with "Yes" and "No"
461462
if it is "Yes" then
462-
delete line (the hilitedLine of field "taskList") of field "taskList"
463+
put the text of field "TaskList" into tList
464+
delete line (the hilitedLine of field "taskList") of tList
465+
set the text of field "TaskList" to tList
463466
end if
464467
end mouseUp
465468
action
@@ -469,7 +472,7 @@ action
469472
end step
470473

471474
step "Run mode 2"
472-
To test the code you have just added enter Run mode and delete the 'Buy milk'
475+
To test the code you have just added enter Run mode and delete the first
473476
task by selecting the line in the list and clicking on the 'Delete' icon.
474477

475478
Start by entering Run mode.
@@ -480,7 +483,7 @@ action
480483
end step
481484

482485
step "Test Delete Task"
483-
Select the 'Buy milk' task and click the 'Delete' icon. Answer 'Yes' when presented with the delete options.
486+
Select the first task and click the 'Delete' icon. Answer 'Yes' when presented with the delete options.
484487

485488
The task will be deleted from the list.
486489
action
@@ -503,43 +506,56 @@ step "Saving Data Interlude"
503506
We want the tasks we add to be saved when we close the app so we need to save the task list when the app is closed and read it in when the app is opened.
504507
action
505508
interlude
506-
go to step "preOpenStack message"
509+
go to step "closeStack handler"
507510
end step
508511

509-
step "preOpenStack message"
510-
When a stack is opened it receives a 'PreOpenStack' message. Any set up can
511-
be done in this handler, before the stack becomes visible to the user.
512+
step "closeStack handler"
513+
When a stack is closed it receives a 'CloseStack' message. Any clean up can
514+
be done in this handler.
515+
516+
In this app we will save the list of tasks before the app is closed. The contents
517+
of the 'TaskList' field are saved to a text file in the 'Documents' folder, ready
518+
to be loaded in the next time the app is opened. There is a 'Documents' folder on all platforms so this code will work on desktop and mobile.
519+
action
520+
interlude
521+
go to step "Open Stack Script"
522+
end step
523+
524+
step "Open Stack Script"
525+
Just like the SVG icons and other objects a Stack can have code associated with it and receive messages.
526+
527+
The CloseStack message is sent to the stack so will be handled on the Stack Script.
512528

513529
Click on the Object menu, and select 'Stack Script' to open the Script Editor for the stack.
514530
action
515531
highlight menu item "Stack Script" of menu "Object"
516532
wait until there is a script editor for stack "Mainstack"
517-
go to step "preOpenStack code"
533+
go to step "closeStack code"
518534
end step
519535

520-
step "preOpenStack code"
521-
When the stack is opened we will load in the saved tasks. The list of tasks is saved in a text file in the 'Documents' folder. There is a 'Documents' folder on all platforms so this code will work on desktop and mobile.
536+
step "closeStack code"
537+
In the closeStack handler we work out the full path to the text file that will be user to store the To To list and save the contents of the field to the text file.
522538

523-
We get the contents of the file and place the list into the 'taskList' field.
539+
Add this handler to the Stack Script and press 'Apply'.
524540
script
525-
on preOpenStack
541+
on closeStack
526542
local tFile
527543
put specialFolderPath("documents") & "/ToDoList.txt" into tFile
528-
put url ("file:" & tFile) into field "taskList"
529-
end preOpenStack
544+
put field "TaskList" into url ("file:" & tFile)
545+
end closeStack
530546
action
531547
highlight script editor for stack "Mainstack"
532548
wait until stack "Mainstack" is scripted
533-
go to step "closeStack message"
549+
go to step "Test step"
534550
end step
535551

536-
step "closeStack message"
537-
When a stack is closed it receives a 'CloseStack' message. Any clean up can
538-
be done in this handler.
552+
step "preOpenStack code"
553+
When a stack is opened it receives a 'PreOpenStack' message. Any set up can
554+
be done in this handler, before the stack becomes visible to the user.
539555

540-
In this app we will save the list of tasks before the app is closed. The contents
541-
of the 'TaskList' field and saved to the text file in the 'Documents' folder, ready
542-
to be loaded in the next time the app is opened.
556+
When the stack is opened we will load in the saved tasks form the text file in the 'Documents' folder.
557+
558+
Add this handler to the Stack Script and press 'Apply'.
543559
script
544560
on preOpenStack
545561
local tFile
@@ -561,8 +577,7 @@ end step
561577
step "Save Standalone"
562578
Before you can prepare your app for sharing you need to set is up to build as a self contained, or 'standalone' app.
563579

564-
You set up this up by selecting the platforms you want to build for and setting the properties for the application. You then choose "Save As Standalone Application..."
565-
from the File menu. This will build the executable files for the selected platforms.
580+
You set up this up by selecting the platforms you want to build for and setting some properties for the app. You then choose "Save As Standalone Application..." from the File menu. This will build the executable files for the selected platforms.
566581

567582
For more details see this lesson
568583
url
@@ -578,7 +593,7 @@ epilogue
578593
That's it, you have finished your app. Switch back to 'Run' mode and try it out.
579594

580595
Why don't you try customizing it by changing some properties such as the
581-
icon colours or task list font and text size.
596+
icon colors or task list font and text size.
582597
image
583598
ToDoListScreenshot2.png
584599
end epilogue

0 commit comments

Comments
 (0)