Page 1 of 1
Palettes and main stack focus
Posted: Fri Aug 26, 2011 4:43 pm
by ibe
1. create a new main stack 'parent'
2. create a new substack for 'parent' called 'child'
3. from the Message Box give command: set the style of stack "child" to palette
4. save the project and remove it from memory
5. open the project
6. from the Message Box give command: show stack 'child'
The child windows decoration is active but the parent's decorations are not. As child is a palette, shouldn't the the parent seem to be the active window. Adding any control to the stack parent will make it's decorations be active and the palette child works correctly (decoration only lights up when the mouse moves over the close button, exactly like the LiveCode Tools palette). Now closing child and calling go stack to it will make this problem reappear.
My question: how do I keep focus (or seem to keep it) on the parent. People must have projects that utilize palettes so I know there must be a solution.
Re: Palettes and main stack focus
Posted: Fri Aug 26, 2011 5:41 pm
by mwieder
As child is a palette, shouldn't the the parent seem to be the active window.
No. You can only have one active window.
exactly like the LiveCode Tools palette
If you make the Tools palette the active window then your stack is no longer the active window. You can only have one at a time. Hovering over a control doesn't make its stack active.
Re: Palettes and main stack focus
Posted: Fri Aug 26, 2011 7:33 pm
by ibe
Ok. I don't really care if a stack is active or not. But in the IDE I can see that the Tools palette can be moved around and still my main stack stays active. So how do I fake the same behaviour?
Re: Palettes and main stack focus
Posted: Fri Aug 26, 2011 9:38 pm
by mwieder
I don't see that. Grabbing the tools palette and moving it makes it the active window.
Re: Palettes and main stack focus
Posted: Sat Aug 27, 2011 4:51 am
by marksmithhfx
mwieder wrote:I don't see that. Grabbing the tools palette and moving it makes it the active window.
Maybe it is different on a Mac.... but when I grab the tools palette or I grab my stack I see no visual difference in either of them. From the look of them there is no distinguishing feature that would lead you to believe one is active and one is not. They never seem to change their appearance?
-- Mark
Re: Palettes and main stack focus
Posted: Sat Aug 27, 2011 12:19 pm
by ibe
I'm on a mac and this is what I see. I open my test stack and give the command go stack "child":

as you can see the palette window is definitely active, it's decoration is showing and the parent's decorations are greyed out. However if I add a button to the parent it's decorations become active and though I move the child stack etc. the decorations in the parent stay on (until I close the child and I get the problem again):

and this is not a faked screen shot. Somehow the behavior I want is possible but I don't see what the difference is.
Re: Palettes and main stack focus
Posted: Sat Aug 27, 2011 2:27 pm
by ibe
Some progress here. If you just have a palette or two, it's simple to get this to work so it looks like the main stack has focus all the time:
1. in the main stacks preOpenStack handler add the lines:
Code: Select all
go stack "child"
set the blendLevel of stack "child" to 100
in the child's stack script add:
Code: Select all
on closeStackRequest
set the blendLevel of me to 100
end closeStackRequest
and when you want to show the child just set it's blend level. Works perfectly.
Having said that, I want to change my palette's shape during runtime and that defeats this method. Once I call set windowShape the child has the focus. If I set the windowShape of the child and then call
Code: Select all
hide stack "parent"
show stack "parent"
the parent seems active but that causes a flicker on the screen so it's not acceptable. I did notice that when I choose Save from LiveCode's File menu the parent becomes active without a flicker but I don't know how to replicate the effect. Basically that's exactly what I need.
Re: Palettes and main stack focus
Posted: Sun Aug 28, 2011 1:15 am
by mwieder
Having said that, I want to change my palette's shape during runtime
Now it's getting clearer what you're trying to do. Forget about active/inactive stacks... try something like this:
Code: Select all
on mouseUp pMouseBtnNo
local tLoc
lock screen
push card -- save the current position
put the loc of stack "child" into tLoc
-- move the child stack offscreen
set the loc of stack "child" to -1000,-1000
set the windowshape of stack "child" to <the id of the windowshape image>
set the loc of stack "child" to tLoc
pop card -- restore the original position
unlock screen
end mouseUp
The push/pop pair should keep your original focus.
Re: Palettes and main stack focus
Posted: Sun Aug 28, 2011 10:29 am
by ibe
Setting the windowShape causes a flicker so it's obviously overriding the lock screen. That wouldn't be a problem but the push/pop solution did not keep focus on the parent. I'll have to try and find some other solution.