Stack mode vs style

J. Landman Gay jacque at hyperactivesw.com
Fri Feb 13 14:48:04 EST 2009


Sarah Reichelt wrote:
> Hi All,
> 
> I am a bit confused about a stack's mode versus it's style. The 2
> seems to do the same things but be able to be set independently and it
> is possible to have them set to conflicting settings.

Actually, "mode" is read-only and so Rev's contextual menu description 
is a little misleading.

The style of a stack determines its default window decorations and 
behavior. It's a permanent property of the stack, like it's name. It can 
be set to something else from a script. When you set the style of a 
stack, you can just use "go" to navigate to it and it will open using 
its assigned style. (If you open it "as <somestyle>", the scripted 
command will override the property setting.) The point being, it's as 
flexible as any other object property.

The mode of a stack can change depending on the stack's current usage 
and is not necessarily permanent. Say you have a toplevel stack; it is 
editable and open, so it has a mode setting of 1. If your script issues 
a "hide stack" command, the style of the stack is still "toplevel" but 
its mode will change to 0, because it is now hidden. When you show it 
again, the mode changes back to 1. If a script sets the stack's 
cantmodify property to true, its mode becomes 2, even though it's still 
a toplevel stack.

A script could check for all stacks with a mode of 0 to find all the 
open but hidden stacks. Or a script could get a list of all stacks that 
were open but not toplevel, regardless of their style, by looking for 
stacks whose mode was > 2. The IDE checks the mode often to determine 
which stack should be the target to send messages to, because sometimes 
it's just easier to script using "mode".

For example, these two lines are roughly equivalent:

   if the mode of stack x = 1 then...

   if not the cantmodify of stack x and the visible of stack x and the 
style of stack x = "toplevel" then...

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list