Page 1 of 1

Opening stack as a palette

Posted: Fri Aug 19, 2011 9:00 pm
by ibe
I want my stack to open as a palette. I did a test stack where the only code was

Code: Select all

on preOpenStack
   palette this stack
   pass preOpenStack
end preOpenStack
no effect. It does get called so that's not the problem. Doesn't work with the openStack handler either. But if I call "palette stack "palette test"" in the Message Window it works. If I add a button with the same code, it works. But I want it to be a palette when it launches.

Re: Opening stack as a palette

Posted: Fri Aug 19, 2011 10:05 pm
by mwieder
I've had trouble with that in a preOpenStack handler as well, but I've found that this works:

Code: Select all

set the style of this stack to "palette"

Re: Opening stack as a palette

Posted: Fri Aug 19, 2011 10:21 pm
by ibe
Thanks, just found it myself in an old forum thread. Works for me too. I wonder why the dictionary has nothing on this.

Re: Opening stack as a palette

Posted: Sat Aug 20, 2011 4:25 pm
by dunbarx
It is a minor bug. If you write, in a top-level stack

Code: Select all

on mouseUp
   set the style of this stack to "palette"
   answer the style of this stack
end mouseUp
You get a palette, and the answer is "palette".

If you write

Code: Select all

on mouseUp
   palette this stack
   answer the style of this stack
end mouseUp
You get a palette, but the answer is "top-level".

Craig Newman

Re: Opening stack as a palette

Posted: Sun Aug 21, 2011 2:12 am
by marksmithhfx
ibe wrote:Thanks, just found it myself in an old forum thread. Works for me too. I wonder why the dictionary has nothing on this.
What about adding a user contributed note?

Re: Opening stack as a palette

Posted: Mon Aug 22, 2011 4:55 pm
by jacque
The "palette" command is working correctly. The style of a stack is a permanent property and allows you to "go" to a stack, knowing it will always open as a palette (or whatever style is set.) The "palette" command will override the property setting on a one-time basis. If you use "palette myStack", the style property remains unchanged and if you just "go" to stack "myStack" later it will display in the original style again.

It's easier to see using the "toplevel" style. By default, all new stacks use style toplevel. You can display it differently on a case by case basis by issuing a command like "palette mystack", but the next time you close and then "go" to that stack it will display as toplevel again. If you ask about the style while it is showing on-screen as a palette, it will report "toplevel", because that's what it is.

Re: Opening stack as a palette

Posted: Mon Aug 22, 2011 5:01 pm
by jacque
ibe wrote:I want my stack to open as a palette. I did a test stack where the only code was

Code: Select all

on preOpenStack
   palette this stack
   pass preOpenStack
end preOpenStack
no effect. It does get called so that's not the problem. Doesn't work with the openStack handler either. But if I call "palette stack "palette test"" in the Message Window it works. If I add a button with the same code, it works. But I want it to be a palette when it launches.
The stack window isn't drawn yet when preOpenStack triggers, so there is nothing onscreen to accomodate a command like "palette" -- which is a command to draw a window. That's why you need to set the style of the stack, so that when it is ready to display, it will display in the style you want.