pointing palette scripts to main stack

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
melristau
Posts: 56
Joined: Tue Jul 14, 2015 5:15 pm
Contact:

pointing palette scripts to main stack

Post by melristau » Tue Jul 19, 2016 1:27 am

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" :oops:
rebuilding visual programming app originally created in 1993 as Hypercard stack

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: pointing palette scripts to main stack

Post by dunbarx » Tue Jul 19, 2016 1:32 am

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

melristau
Posts: 56
Joined: Tue Jul 14, 2015 5:15 pm
Contact:

Re: pointing palette scripts to main stack

Post by melristau » Tue Jul 19, 2016 3:20 am

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.
rebuilding visual programming app originally created in 1993 as Hypercard stack

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: pointing palette scripts to main stack

Post by dunbarx » Tue Jul 19, 2016 3:49 am

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

melristau
Posts: 56
Joined: Tue Jul 14, 2015 5:15 pm
Contact:

Re: pointing palette scripts to main stack

Post by melristau » Tue Jul 19, 2016 4:39 am

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
Attachments
palettetomain.gif
palettetomain.gif (3.33 KiB) Viewed 6454 times
rebuilding visual programming app originally created in 1993 as Hypercard stack

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: pointing palette scripts to main stack

Post by Klaus » Tue Jul 19, 2016 12:19 pm

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

melristau
Posts: 56
Joined: Tue Jul 14, 2015 5:15 pm
Contact:

Re: pointing palette scripts to main stack

Post by melristau » Tue Jul 19, 2016 7:57 pm

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.
Attachments
palette.jpg
rebuilding visual programming app originally created in 1993 as Hypercard stack

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: pointing palette scripts to main stack

Post by mwieder » Tue Jul 19, 2016 8:15 pm

Issued command to start using stack "planToolBar" :oops:
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

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: pointing palette scripts to main stack

Post by Klaus » Tue Jul 19, 2016 8:28 pm

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
...
:D

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: pointing palette scripts to main stack

Post by jacque » Wed Jul 20, 2016 5:17 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

melristau
Posts: 56
Joined: Tue Jul 14, 2015 5:15 pm
Contact:

Re: pointing palette scripts to main stack

Post by melristau » Mon Jul 25, 2016 4:14 pm

Thanks for instructions! Most helpful. I am learning.
rebuilding visual programming app originally created in 1993 as Hypercard stack

Post Reply