Identifying Current Stack (Solved)

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
Xero
Posts: 152
Joined: Sat Jun 23, 2018 2:22 pm

Identifying Current Stack (Solved)

Post by Xero » Mon Aug 12, 2019 2:42 pm

I feel so stupid asking this, but the documentation is a little light and I can't seem to get the right words...

I have an app with multiple stacks.
I have a script that appears in an object that gets cloned to all stacks. In that script, I want certain sections to work only on certain stacks, and not others. So, I need to identify "the current stack" somehow. 'the topStack' seems to be the function I need, but I can't get it to work.

Here's a sample script:

Code: Select all

 on mousedown
 if the topstack is "Image" then
 if gCurrentAction = "Grid" then
 --do grid things--
 end if
 end if
So, when the mouse is clicked in stack "Image", and the current action is "Grid", it should do all the things in the statement --do grid things--. When the mouse is clicked in stack "ColourPicker" nothing should happen because it's the wrong stack for that action.
But that doesn't seem to work.
How do I work out what the name of the stack is where the mouse is clicking?
Thanks in Advance
X
Last edited by Xero on Mon Aug 12, 2019 4:02 pm, edited 1 time in total.

Klaus
Posts: 13820
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Identifying Current Stack

Post by Klaus » Mon Aug 12, 2019 3:01 pm

Hi Xero,

the dictionary is waaaaaaay better that its reputation! 8)
"the topstack" returns the LONG name of the current topstack, so you would need to do something like:

Code: Select all

...
if the short name of the topstack = "Image" then
...
You could also check -> the mousestack, if that fits your situation better.
That returns the name of the stack the cursor is currently over (topstack or not!):

Code: Select all

...
if the short name of the mousestack = "Image" then
...
Best

Klaus

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Identifying Current Stack

Post by bogs » Mon Aug 12, 2019 3:12 pm

Actually, I was thinking more along the lines of something like -

Code: Select all

on mouseDown
   if the short name of this stack is "Image" then answer the name of this stack // do grid things...
end mouseDown
... which seems to work perfectly in testing here.
Image

Xero
Posts: 152
Joined: Sat Jun 23, 2018 2:22 pm

Re: Identifying Current Stack

Post by Xero » Mon Aug 12, 2019 3:13 pm

As always Klaus! Works like a charm.
:D
The Dictionary does say "Long name", but us dummies don't know we need to ask for the short name! And one of the examples simply reads "the topStack" which doesn't help much... and it actually needs 'the' at the start of it too...
Us dummies need it spelled out! Ha ha ha.
Thanks again.
X

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”