You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
capture the next new widget of stack "Mainstack" as "delete"
@@ -401,7 +400,7 @@ action
401
400
end step
402
401
403
402
step "Set Delete Location"
404
-
Position the icon, as shown.
403
+
Resize and position the icon, as shown.
405
404
action
406
405
add guide "deleteLoc" with rect "240,10,270,40" to stack "Mainstack"
407
406
highlight guide "deleteLoc"
@@ -412,7 +411,7 @@ end step
412
411
step "Open Delete Property Inspector"
413
412
Next we need to set the properties of the 'Delete' icon.
414
413
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
416
415
SVG icon.
417
416
action
418
417
highlight toolbar "Inspector"
@@ -421,7 +420,7 @@ action
421
420
end step
422
421
423
422
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.
425
424
action
426
425
highlight property "name" of section "Basic"
427
426
wait until the name of widget "delete" is "Delete"
@@ -440,7 +439,7 @@ action
440
439
end step
441
440
442
441
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.
444
443
action
445
444
highlight toolbar "Code"
446
445
wait until there is a script editor for widget "delete"
@@ -457,9 +456,13 @@ step "Delete mouseUp"
457
456
Don't forget to click the 'Apply' button when you have added the code.
458
457
script
459
458
on mouseUp
459
+
local tList
460
+
460
461
answer "Do you want to delete this task?" with "Yes" and "No"
461
462
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
463
466
end if
464
467
end mouseUp
465
468
action
@@ -469,7 +472,7 @@ action
469
472
end step
470
473
471
474
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
473
476
task by selecting the line in the list and clicking on the 'Delete' icon.
474
477
475
478
Start by entering Run mode.
@@ -480,7 +483,7 @@ action
480
483
end step
481
484
482
485
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.
484
487
485
488
The task will be deleted from the list.
486
489
action
@@ -503,43 +506,56 @@ step "Saving Data Interlude"
503
506
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.
504
507
action
505
508
interlude
506
-
go to step "preOpenStack message"
509
+
go to step "closeStack handler"
507
510
end step
508
511
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.
512
528
513
529
Click on the Object menu, and select 'Stack Script' to open the Script Editor for the stack.
514
530
action
515
531
highlight menu item "Stack Script" of menu "Object"
516
532
wait until there is a script editor for stack "Mainstack"
517
-
go to step "preOpenStack code"
533
+
go to step "closeStack code"
518
534
end step
519
535
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.
522
538
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'.
524
540
script
525
-
on preOpenStack
541
+
on closeStack
526
542
local tFile
527
543
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
530
546
action
531
547
highlight script editor for stack "Mainstack"
532
548
wait until stack "Mainstack" is scripted
533
-
go to step "closeStack message"
549
+
go to step "Test step"
534
550
end step
535
551
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.
539
555
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'.
543
559
script
544
560
on preOpenStack
545
561
local tFile
@@ -561,8 +577,7 @@ end step
561
577
step "Save Standalone"
562
578
Before you can prepare your app for sharing you need to set is up to build as a self contained, or 'standalone' app.
563
579
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.
566
581
567
582
For more details see this lesson
568
583
url
@@ -578,7 +593,7 @@ epilogue
578
593
That's it, you have finished your app. Switch back to 'Run' mode and try it out.
579
594
580
595
Why don't you try customizing it by changing some properties such as the
0 commit comments