Page 1 of 1
Detect app activation (focus) [SOLVED]
Posted: Tue Apr 05, 2016 9:39 am
by sooshi
Hi everybody.
I have a stack with an hidden card, that runs as a standalone. I am polling the keyboard to see if a key is pressed, then i rise up my card.
I want to do the same when the icon of the standalone is pressed (so if one clicks with mouse on dock or windows task bar).
In substance i need to detect when my app is activated in any way, but cannot find any message to capture.
Any hint?
Re: Detect app activation (focus)
Posted: Tue Apr 05, 2016 9:46 am
by Klaus
Hi sooshi,
maybe the "resumestack" message is what you are looking for?
That is sent to the foremost stack when the standalone app get focus again.
Best
Klaus
Re: Detect app activation (focus)
Posted: Tue Apr 05, 2016 9:53 am
by Dixie
read up on 'iconify'stack in the dictionary...
Re: Detect app activation (focus)
Posted: Tue Apr 05, 2016 10:00 am
by sooshi
Thank everybody.
None of this seems to work
Now i have:
Code: Select all
on resumeStack
answer "Resume"
end resumeStack
on iconifyStack -- hide auxiliary window when the stack is iconified
answer "iconify"
end iconifyStack
on uniconifyStack -- hide auxiliary window when the stack is iconified
answer "uniconiify"
end uniconifyStack
but when i click on the icon on the dock, none of these 'answers' ...
Re: Detect app activation (focus)
Posted: Tue Apr 05, 2016 10:09 am
by Dixie
The handler is in the stack script... this works for me on MacOSX El Capitain.. LC 7.1.3
Code: Select all
on uniconifyStack
beep
end uniconifyStack
Re: Detect app activation (focus)
Posted: Tue Apr 05, 2016 10:18 am
by sooshi
I'm on macosx El Capitain also, and with LC 7.1.3
Code: Select all
on uniconifyStack
beep
end uniconifyStack
does not work.
Maybe because my standalone has no visible stacks, so there is nothing to 'uniconify' ...
Re: Detect app activation (focus)
Posted: Tue Apr 05, 2016 10:55 am
by sooshi
Here is my code (stripped down version).
Basically i have a splash screen, then i want my app substack to pop up when user press a key combo (here shift + ctrl). And this works (on mac).
But i also would like to open app substack when user clicks on the icon of the standalone in the doc.
Re: Detect app activation (focus)
Posted: Wed Apr 06, 2016 2:08 pm
by sooshi
A little progress.
Now i don't hide the stack, but move it to -500 (out of video viewport). Now i can correctly get the event resume, but if app still has the focus, i cannot get click on dock icon, so i cannot redisplay the app window.
Any hint? Is it possible to capture the click on the icon of a standalone (with or without the app in focus)?
Re: Detect app activation (focus)
Posted: Sun Apr 10, 2016 6:00 pm
by [-hh]
Clicking on a dock icon of an
*app* is a
*system event*, which the app has to pass to the card/stack.
The following works in the IDE, should also work in a standalone. Just try.
Code: Select all
-- put into first card's script or stack's script
on appleEvent iClass,iID,iBlah
put the internet date && the params into fld 1 --> for debugging
if iID is "rapp" then
send "asYouLikeIt" to me in 2 ticks --> give some time for activation!!
end if
pass appleEvent
end appleEvent
on asYouLikeIt
answer "I like It"
end asYouLikeIt
Re: Detect app activation (focus) [SOLVED]
Posted: Mon Apr 11, 2016 3:20 pm
by sooshi
Ty very much, this seems to solve my issue for now!