Page 1 of 1
pointing palette scripts to main stack
Posted: Tue Jul 19, 2016 1:27 am
by melristau
Made a substack and copy/pasted several buttons from main stack to palette.
The palette is set to the reference my main stack (object property)
loading it with: palette stack "planToolBar"
Those pasted buttons are no longer functional and not clear on the message path for palette.
How to point palette scripts to main stack?
Issued command to start using stack "planToolBar"

Re: pointing palette scripts to main stack
Posted: Tue Jul 19, 2016 1:32 am
by dunbarx
Hi.
I am not sure what your issue is. Unless someone else knows, can you give a step by step process so we can duplicate what you are seeing?
Craig Newman
Re: pointing palette scripts to main stack
Posted: Tue Jul 19, 2016 3:20 am
by melristau
Thanks dunbarx
I went through the process again with same result.
All the buttons in the palette are same btn scripts that use to reside on the main stack cd 1. (just copied and pasted)
1) Tried creating a substack for the palette
2) Tried creating a new main stack and pointing it to my main main stack.
The palette buttons are calling a handler placed in the main stack and returning "can't find handler" error.
Re: pointing palette scripts to main stack
Posted: Tue Jul 19, 2016 3:49 am
by dunbarx
The palette buttons are calling a handler placed in the main stack and returning "can't find handler" error.
Hmmm.
Because you copied buttons from one stack into another, that does not mean that those buttons can access handlers in the source stack. The message hierarchy is rigid. A button that lives in a stack might pass messages along the hierarchy starting from that button, that is, to the objects above that button, groups, card, stack, and farther...
But placing such a button in another stack puts it in a different message path hierarchy, and that will not include that original source stack.
There are many ways to fix this, but I would need just a little more information about the handlers in those buttons to be able to direct you best. For example, I assume that the buttons in question sent, say, a "mouseUp" message to a handler in the stack script. is something like this the case? If so, do you see what I meant above?
Craig
Re: pointing palette scripts to main stack
Posted: Tue Jul 19, 2016 4:39 am
by melristau
Yes, each of the palette buttons contain same script:
Code: Select all
on mouseUp
global gPlaceThis
put the short name of me into gPlaceThis
put the short name of me into fld "placeThis"
toggleImages -- error
end mouseUp
toggleimages resides in the main stack's script
Re: pointing palette scripts to main stack
Posted: Tue Jul 19, 2016 12:19 pm
by Klaus
Hi Mel,
sure all the handlers/functions are in the STACK script and not in the script of cd 1 of the mainstack?
Ususally all substacks can execute all handlers/function that are in the main stacks script!
Best
Klaus
Re: pointing palette scripts to main stack
Posted: Tue Jul 19, 2016 7:57 pm
by melristau
Thanks Klaus
What am i doing wrong??
"Planner" is my main stack with handlers in the stack script (not cd script)
Made New Substack of "Planner"
Copied and pasted buttons in "Planner" to "Planner Tools" (my palette)
Code: Select all
on mouseUp
global gPlaceThis
put the short name of me into gPlaceThis
toggleImages
end mouseUp
Called palette with
palette stack "Planner Tools"
For what its worth, here is the handler being called from palette:
Code: Select all
on toggleImages
global gPlaceThis
put "" into msg
if gPlaceThis is "link" then put "L-list" into gPlaceThis
else
if gPlaceThis is "end" then put "E-list" into gPlaceThis
else
if gPlaceThis is "begin" then put "B-list" into gPlaceThis
else
if gPlaceThis is "timer" then put "T-list" into gPlaceThis
else
if gPlaceThis is "performance" then put "P-list" into gPlaceThis
else
if gPlaceThis is "decision" then put "D-list" into gPlaceThis
else
if gPlaceThis is "path" then put "H-list" into gPlaceThis
end if
end if
end if
end if
end if
end if
put gPlaceThis into msg
--show the images in the tileset
repeat with x = 1 to (the number of lines in fld gPlaceThis)
put line x of fld gPlaceThis into showIt
if there is a img showIt is false then
put return&showIt&"!!false!!" after msg
end if
if there is a img showIt then
put return&showIt&",true" after msg
set the visible of img showit to true
set the loc of img showit to the loc of btn ("x"&x)
else next repeat
end repeat
--
--show the images in the tileset
if the optionKey is down then
repeat with x = 1 to (the number of lines in fld gPlaceThis)
put line x of fld gPlaceThis into hideIt
if there is a img showIt is false then
put return&showIt&"!!false!!" after msg
end if
if there is a img hideIt then
set the visible of img hideIt to false
else next repeat
end repeat
end if
end toggleImages
Doesn't seem to know that the images are present in main stack.
Re: pointing palette scripts to main stack
Posted: Tue Jul 19, 2016 8:15 pm
by mwieder
Issued command to start using stack "planToolBar"

why?
Also, just referencing an image by name (img showIt) won't reference the mainstack if you're calling the handler from the substack.
Try making the reference explicit:
Code: Select all
if there is a img showIt of stack "Planner"
or possibly (untested)
Code: Select all
if there is a img showIt of stack the mainstack of me
Re: pointing palette scripts to main stack
Posted: Tue Jul 19, 2016 8:28 pm
by Klaus
What Mark said, in cases like this you need to add a complete descriptor for your objects!
And for readability, get used to the SWITCH structure:
Code: Select all
on toggleImages
global gPlaceThis
put "" into msg
switch gPlaceThis
case "link"
put "L-list" into gPlaceThis
break
case "end"
put "E-list" into gPlaceThis
break
case "begin"
put "B-list" into gPlaceThis
break
case "timer"
put "T-list" into gPlaceThis
break
case "performance"
put "P-list" into gPlaceThis
break
case "decision"
put "D-list" into gPlaceThis
break
case "path"
put "H-list" into gPlaceThis
break
end switch
...

Re: pointing palette scripts to main stack
Posted: Wed Jul 20, 2016 5:17 pm
by jacque
Another way to make it work is to set the defaultstack at the top of the handler:
set the defaultstack to "Planner"
After that, all object references will point to the mainstack. This avoids the need for long object references.
Re: pointing palette scripts to main stack
Posted: Mon Jul 25, 2016 4:14 pm
by melristau
Thanks for instructions! Most helpful. I am learning.