Auto show/hide palette when app gains/loses focus

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
xeir
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 35
Joined: Thu Jul 03, 2008 5:54 am

Auto show/hide palette when app gains/loses focus

Post by xeir » Thu Sep 11, 2008 1:32 am

After a bit of searching, reading and even digging into the built-in rev stacks for a solution, I'm still at a loss.

I have my main stack and a few sub-stacks that get called as certain functions are processed. Above and beyond all else, I have 1 sub-stack, a search bar, that is currently a floating palette that moves with the main stack. It use to be a drawer .. but, well, I'm sure you know how that tends to turn out.

The problem I have is.. Since the palette floats above all else, it stays in front even when the app has lost focus or even minimized. I need a way to have the palette either hide itself automatically or change to another type that will not hinder the view when the app either has or has lost focus appropriately.

Does anyone know of a way to do this by chance? Any insight would be greatly appreciated.

I was also looking for a way to have the palette change to a different window type when it is in the dev environment so that it does not obscure the view while developing.

Regards!

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Thu Sep 11, 2008 5:56 am

A couple of things to check:
- is the stack really opened as a palette (sorry, had to ask) ?
- is the 'systemWindow' stack property by any chance set to 'true'?
- what is the 'style' property and the 'mode' property of the stack?
- what is the content of the 'hidePalettes' global property?

Don't worry, you've come to the right place - we'll get there :-)

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Sep 11, 2008 1:15 pm

Dear Xeir,

You might want to read about the hidePalettes property, the iconyfyStack and the uniconifyStack messages in the docs.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

xeir
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 35
Joined: Thu Jul 03, 2008 5:54 am

Post by xeir » Thu Sep 11, 2008 3:54 pm

Jan / Mark -

Both of you got me pointed in the right direction, thank you.

I had previously set the 'systemwindow' to true in one of my earlier attempts of trying to get the layout the way I wanted, and never set it back to false.

And I just found one of the other message I was looking for, 'environment' so that I can set the stack to change behavior appropriately.

The (un)iconifyStack stack messages I had been looking for to do some extra handling, so that answered one of my next questions.

Ah, just found the 'lock moves' command, I knew there was a way to get rid of the springiness in the window when I moved the stacks.

If you haven't guessed, multitasking is habit. Correcting one issue while still looking for answers to another, grin.

Have to say, I don't think I've ever felt like the proverbial 'kid in a candy store' when programming before. Well except when I first started perhaps.

Here's another question if I may as I've looked yet still not been able to find the bugger ...
Is there by chance a message for telling when an application has lost focus, no longer the active or frontmost app?

Appreciate the help, I knew there was a way to get the layout closer to the way I wanted.

Now to try and figure out why some data intermittently hides itself in 2 of my tables.

Thanks again!

Fred

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Sep 11, 2008 5:09 pm

Hi Fred,

Usually, I set a custom property when the suspend or resume message is sent:

Code: Select all

on suspend
  set the suspended of this stack to true
  pass suspend
end suspend

on resume
  set the suspended of this stack to false
  pass resume
end resume
This way, I can always use the suspended custom property to determine whether the programme is the frontmost application.

(Normally, I start the name of a custom property with "c", but in some cases I prefer to mimic a native Revolution property, that's why I call it suspended instead of cSuspended)

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Post by Garrett » Thu Sep 11, 2008 8:51 pm

Here's what I used some time ago

Code: Select all

on suspend
  if field "LabelToolsStatus" of card "cardmgdmain" of stack "mgdmain" is 1 then
    hide stack "mgdtools"
  end if
  if field "LabelPropsStatus" of card "cardmgdmain" of stack "mgdmain" is 1 then
    hide stack "mgdprops"
  end if
  if field "LabelDesignStatus" of card "cardmgdmain" of stack "mgdmain" is 1 then
    hide stack "designwindow"
  end if
end suspend


on resume
  if field "LabelToolsStatus" of card "cardmgdmain" of stack "mgdmain" is 1 then
    show stack "mgdtools"
  end if
  if field "LabelPropsStatus" of card "cardmgdmain" of stack "mgdmain" is 1 then
    show stack "mgdprops"
  end if
  if field "LabelDesignStatus" of card "cardmgdmain" of stack "mgdmain" is 1 then
    show stack "designwindow"
  end if
end resume



on iconifyStack
  if field "LabelToolsStatus" of card "cardmgdmain" of stack "mgdmain" is 1 then
    hide stack "mgdtools"
  end if
  if field "LabelPropsStatus" of card "cardmgdmain" of stack "mgdmain" is 1 then
    hide stack "mgdprops"
  end if
  if field "LabelDesignStatus" of card "cardmgdmain" of stack "mgdmain" is 1 then
    hide stack "designwindow"
  end if
end iconifyStack


on unIconifyStack
  if field "LabelToolsStatus" of card "cardmgdmain" of stack "mgdmain" is 1 then
    show stack "mgdtools"
  end if
  if field "LabelPropsStatus" of card "cardmgdmain" of stack "mgdmain" is 1 then
    show stack "mgdprops"
  end if
  if field "LabelDesignStatus" of card "cardmgdmain" of stack "mgdmain" is 1 then
    show stack "designwindow"
  end if
end unIconifyStack
This code is in my main stack script, and it works just fine for me, no custom properties or anything.

xeir
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 35
Joined: Thu Jul 03, 2008 5:54 am

Post by xeir » Fri Sep 12, 2008 2:31 am

That's exactly what I was looking for: suspend/resume, just didn't have a clue as to what they were called to reference them.

Sometimes, what should be obvious just isn't on occasion.

Thanks for the info and examples!

Fred

Post Reply