Is there a way of telling whether or not the the stack has the current application focus? Basically, I'd like to know if it's hidden (OS X), minimized (OS X/Win32) or not the current top-level application. I can use the mode of the stack to tell if it's minimized, but not any of the others.
Basically, I have my app interfacing with Growl just fine, but I only want to popup Growl notifications if the user is off doing something else and Growl would be letting the user know "hey, something's up and you may want to go check it out.."
Thanks!
Jeff M.
Determining if the stack has the focus
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
Re: Determining if the stack has the focus
When your app is sent to the background, the current card receives a suspend event, and when it comes back to the foreground, the current card receives a resume event. So you can do something like this in your mainstack script:
HTH,
Jan Schenkel.
Code: Select all
on suspend
set the uSuspended of me to true
end suspend
on resume
set the uSuspended of me to false
end resume
command NotifyUser pNotification
if the uSuspended of me then
-- we're in the background, so use Growl
else
-- we're in the foreground, so use in-app notification
end if
end NotifyUser
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
Re: Determining if the stack has the focus
Also, if you only want to know which stack window has focus (as opposed to the whole app) then you can catch "suspendStack" and "resumeStack". They work the same way as Jan's example, only on a stack-by-stack basis. When a stack recieves a resumeStack message, it's on top and has focus.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com