Detect app activation (focus) [SOLVED]

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
sooshi
Posts: 6
Joined: Tue Apr 05, 2016 9:34 am

Detect app activation (focus) [SOLVED]

Post by sooshi » Tue Apr 05, 2016 9:39 am

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?
Last edited by sooshi on Mon Apr 11, 2016 3:20 pm, edited 1 time in total.

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Detect app activation (focus)

Post by Klaus » Tue Apr 05, 2016 9:46 am

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

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Detect app activation (focus)

Post by Dixie » Tue Apr 05, 2016 9:53 am

read up on 'iconify'stack in the dictionary...

sooshi
Posts: 6
Joined: Tue Apr 05, 2016 9:34 am

Re: Detect app activation (focus)

Post by sooshi » Tue Apr 05, 2016 10:00 am

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' ...

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Detect app activation (focus)

Post by Dixie » Tue Apr 05, 2016 10:09 am

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

sooshi
Posts: 6
Joined: Tue Apr 05, 2016 9:34 am

Re: Detect app activation (focus)

Post by sooshi » Tue Apr 05, 2016 10:18 am

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' ...

sooshi
Posts: 6
Joined: Tue Apr 05, 2016 9:34 am

Re: Detect app activation (focus)

Post by sooshi » Tue Apr 05, 2016 10:55 am

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.
Attachments
StrippedDown.livecode.zip
(2.55 KiB) Downloaded 237 times

sooshi
Posts: 6
Joined: Tue Apr 05, 2016 9:34 am

Re: Detect app activation (focus)

Post by sooshi » Wed Apr 06, 2016 2:08 pm

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)?

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Detect app activation (focus)

Post by [-hh] » Sun Apr 10, 2016 6:00 pm

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
shiftLock happens

sooshi
Posts: 6
Joined: Tue Apr 05, 2016 9:34 am

Re: Detect app activation (focus) [SOLVED]

Post by sooshi » Mon Apr 11, 2016 3:20 pm

Ty very much, this seems to solve my issue for now!

Post Reply