Detect app activation (focus) [SOLVED]
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Detect app activation (focus) [SOLVED]
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?
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?
Last edited by sooshi on Mon Apr 11, 2016 3:20 pm, edited 1 time in total.
Re: Detect app activation (focus)
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
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)
read up on 'iconify'stack in the dictionary...
Re: Detect app activation (focus)
Thank everybody.
None of this seems to work
Now i have:
but when i click on the icon on the dock, none of these 'answers' ...
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
Re: Detect app activation (focus)
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)
I'm on macosx El Capitain also, and with LC 7.1.3
does not work.
Maybe because my standalone has no visible stacks, so there is nothing to 'uniconify' ...
Code: Select all
on uniconifyStack
beep
end uniconifyStack
Maybe because my standalone has no visible stacks, so there is nothing to 'uniconify' ...
Re: Detect app activation (focus)
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.
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.
- Attachments
-
- StrippedDown.livecode.zip
- (2.55 KiB) Downloaded 237 times
Re: Detect app activation (focus)
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)?
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)
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.
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
shiftLock happens
Re: Detect app activation (focus) [SOLVED]
Ty very much, this seems to solve my issue for now!