Palettes and main stack focus

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
ibe
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 61
Joined: Sun Oct 04, 2009 12:15 pm

Palettes and main stack focus

Post by ibe » Fri Aug 26, 2011 4:43 pm

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.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Palettes and main stack focus

Post by mwieder » Fri Aug 26, 2011 5:41 pm

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.

ibe
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 61
Joined: Sun Oct 04, 2009 12:15 pm

Re: Palettes and main stack focus

Post by ibe » Fri Aug 26, 2011 7:33 pm

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?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Palettes and main stack focus

Post by mwieder » Fri Aug 26, 2011 9:38 pm

I don't see that. Grabbing the tools palette and moving it makes it the active window.

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

Re: Palettes and main stack focus

Post by marksmithhfx » Sat Aug 27, 2011 4:51 am

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
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

ibe
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 61
Joined: Sun Oct 04, 2009 12:15 pm

Re: Palettes and main stack focus

Post by ibe » Sat Aug 27, 2011 12:19 pm

I'm on a mac and this is what I see. I open my test stack and give the command go stack "child":
Image
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):
Image
and this is not a faked screen shot. Somehow the behavior I want is possible but I don't see what the difference is.

ibe
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 61
Joined: Sun Oct 04, 2009 12:15 pm

Re: Palettes and main stack focus

Post by ibe » Sat Aug 27, 2011 2:27 pm

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.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Palettes and main stack focus

Post by mwieder » Sun Aug 28, 2011 1:15 am

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.

ibe
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 61
Joined: Sun Oct 04, 2009 12:15 pm

Re: Palettes and main stack focus

Post by ibe » Sun Aug 28, 2011 10:29 am

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.

Post Reply