Script Only Stack Architecture
Sannyasin Brahmanathaswami
brahma at hindu.org
Wed Mar 30 19:03:47 EDT 2016
Monte:
Thanks for the thoughtful response.
For now, even the basics would help... in the dictionary... I had to test this morning to learn things that could all be placed on a single page of documentation
1) create a script only stack. Save to disk and leave open call it "behavior-field-text.livecodescript)
2) create field; set behavior, aha! my new script only stack is available.
3) assign the stack to the field -- should accept on mousup, field is locked and the behavior refers to "me") for testing the behavior stack has a simple:
on mouseup
answer "from stack behavior"
put the formattedheight of me into tTotalTextHeight
put ( the height of me - tTotalTextHeight ) / 2 into tTopBottomMargins
set topmargin of me to tTopBottomMargins
end mouseUp
4) lock field, click on field... nothing happens .... aaaahhh (blink)
5) go to the message box... on a hunch type
"start using behavior-field-text.livecodesript"
6) click on field ... Oh, it works now!
7) save stack quit LC
8) boot LC again... open main stack with field that has the behavior
9) click on field that has behavior assign, Oh gosh... now it doesn't work.
10) But wait... inspect field the behavior is assigned to "behavior-field-text.livecodesript"
-- Why doesnt' it work... duh
11) to go main stack, preopenstack handler add this:
put specialFolderPath("Resources") into tAppRoot
start using stack (tAppRoot &"/"&"/main-stack-scripts/behaviors/sv_field-behaviors.livecode"
12) from msg box run "preopenstack" -- my behavior stack is now in use, theoretically.
13) Note that only one field has this stack behavior assigned
but now: any mouseup anywhere on the UI triggers the script.. mouseup msg from anywhere is intercepted by the script-only-stack that is assigned to just a single field.
Also: reference to "me" obviously lost and the behavior script thinks "me" refers to itself and not the child field.
[X] executing at 12:42:02 PM<http://airmail.calendar/2016-03-30%2012:42:02%20HST>
Type Object: does not have this property
Object sv_field-behaviors
Line put the formattedheight of me into tTotalTextHeight
Hint mouseup
14) move that script to a button... change the field behavior to that button.
on mouseup
answer "from btn behavior"
put the formattedheight of me into tTotalTextHeight
put ( the height of me - tTotalTextHeight ) / 2 into tTopBottomMargins
set topmargin of me to tTopBottomMargins
end mouseUp
and it works out of the box...
--- pretty much a complete nightmare...lost all day yesterday<http://airmail.calendar/2016-03-29%2012:00:00%20HST> and all morning today<http://airmail.calendar/2016-03-30%2012:00:00%20HST>...
Sure what I hope for is a full scope architecture thing...
but for now: We are not asking for a lot, just enough to understand how to make it work?
Since this model has been in use since 6.5 or something like that... clearly it works. Can we just document how?
unable to assign behavior to script-only-stack.
What am I Missing?
BR
More information about the use-livecode
mailing list