Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Apr 27, 2017 1:33 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: How to know what window is active
PostPosted: Tue May 21, 2013 11:55 am 
Offline

Joined: Thu Feb 03, 2011 11:47 am
Posts: 130
I should know this but I don't: how can I tell which window is presently active (or perhaps better stated, has the focus)?


Top
 Profile  
 
 Post subject: Re: How to know what window is active
PostPosted: Tue May 21, 2013 3:30 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Window(0) is the topmost of your windows, and would be the one with focus if your app has focus. But it doesn't tell you which of the many apps running on the machine has focus. Finding that is platform specific and requires a different mechanism for each platform.


Top
 Profile  
 
 Post subject: Re: How to know what window is active
PostPosted: Tue May 21, 2013 6:44 pm 
Offline
User avatar

Joined: Sun Jan 25, 2009 5:11 pm
Posts: 576
Location: Guatemala, Central America
I've handled this many different ways but a simple approach I've used is to have a global property that is updated each time a window gets focus, something like App.ActiveWindow and check against it when I need to find out which was the last window that got focus. Yup, not elegant but for simple stuff it works for me.

_________________
Future RS guru.
Ride the world!


Top
 Profile  
 
 Post subject: Re: How to know what window is active
PostPosted: Thu May 23, 2013 6:12 pm 
Offline

Joined: Thu Feb 03, 2011 11:47 am
Posts: 130
Thanks both of you.

I guess I'll choose the second route -- a global property. I thought there must be some property that says if a window is topmost and focused at any given time.

Thanks again.


Top
 Profile  
 
 Post subject: Re: How to know what window is active
PostPosted: Thu May 23, 2013 6:19 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Not to quibble, but the "last window that got focus" is already tracked for you by the system as Window(0). Neither approach tells you if that window actually has focus, though, or if some other app has focus. You didn't specify whether you cared one way or the other, but if you do need to know whether any window in your app actually has focus, you'll need to call some OS-specific methods, such as declares or applescript.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group