Palettising a 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
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9746
Joined: Fri Feb 19, 2010 10:17 am

Palettising a main stack.

Post by richmond62 » Thu Apr 25, 2024 4:41 pm

I should like a main stack to appear as a palette, but this in the stack script does nothing:

Code: Select all

on openStack
palette me
end openStack

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4102
Joined: Sun Jan 07, 2007 9:12 pm

Re: Palettising a main stack.

Post by bn » Thu Apr 25, 2024 6:07 pm

richmond62 wrote:
Thu Apr 25, 2024 4:41 pm
I should like a main stack to appear as a palette, but this in the stack script does nothing:

Code: Select all

on openStack
palette me
end openStack
try:

Code: Select all

on openStack
   palette this stack
end openStack
Kind regards
Bernd

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

Re: Palettising a main stack.

Post by dunbarx » Thu Apr 25, 2024 8:13 pm

Richmond.

"Me" really cannot be used that way. It only refers to the object that contains a running handler. So you could make this work if you put your original handler in the stack script.

Craig

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

Re: Palettising a main stack.

Post by dunbarx » Thu Apr 25, 2024 8:17 pm

Well, more complicated than I thought.

If your handler is in the stack script, it does not work. But if it is this:

Code: Select all

on mouseUp
   palette me
end mouseUp
it work fine.

Craig

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

Re: Palettising a main stack.

Post by dunbarx » Thu Apr 25, 2024 8:19 pm

Well, more complicated than I thought.

If your handler is in the stack script, it does not work. The openStack handler fires but nothing happens. But if it is this in the stack script:

Code: Select all

on mouseUp
   palette me
end mouseUp
it work fine if you click on the card window.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9960
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Palettising a main stack.

Post by FourthWorld » Thu Apr 25, 2024 10:27 pm

Use the stack's style property and you'll need no code at all.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

stam
Posts: 2990
Joined: Sun Jun 04, 2006 9:39 pm

Re: Palettising a main stack.

Post by stam » Fri Apr 26, 2024 5:58 am

dunbarx wrote:
Thu Apr 25, 2024 8:19 pm
Well, more complicated than I thought.

If your handler is in the stack script, it does not work. The openStack handler fires but nothing happens. But if it is this in the stack script:

Code: Select all

on mouseUp
   palette me
end mouseUp
it work fine if you click on the card window.

Craig
I’ve always used

Code: Select all

Set the style of this stack to “palette”
and it always works fine in preOpenStack

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9960
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Palettising a main stack.

Post by FourthWorld » Fri Apr 26, 2024 6:39 am

stam wrote:
Fri Apr 26, 2024 5:58 am
I’ve always used

Code: Select all

Set the style of this stack to “palette”
and it always works fine in preOpenStack
Best of all, the style property is persistent. Set it once, save it, and that's the mode it'll open in forever.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

stam
Posts: 2990
Joined: Sun Jun 04, 2006 9:39 pm

Re: Palettising a main stack.

Post by stam » Fri Apr 26, 2024 6:42 am

FourthWorld wrote:
Fri Apr 26, 2024 6:39 am
Best of all, the style property is persistent. Set it once, save it, and that's the mode it'll open in forever.

Sure.

However sometimes it’s of value to do this conditionally, especially especially when working on the stack.

For example, prefixing that statement with

Code: Select all

if the optionKey is not down then…
I just posted what code works for me. But sure, if no need to set this dynamically I just set this in the property inspector for the stack…

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9960
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Palettising a main stack.

Post by FourthWorld » Fri Apr 26, 2024 8:01 am

Yes, it's good to have options.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”