Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / November 2004



Tip: Looking for answers? Try searching our database.

Which window had focus

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert W. Kuhn - 24 Nov 2004 13:23 GMT
Hello,

I have a windowcontroller and coded a
- (void)windowDidBecomeKey:(NSNotification *)aNotification

What I do want to know is which window had the focus before my window
gets the focus. How can I do that?

Thanks and bye - Robert
Robert W. Kuhn - 24 Nov 2004 13:52 GMT
Robert W. Kuhn <robert.w.kuhn@gmail.com> schrieb:

> I have a windowcontroller and coded a
> - (void)windowDidBecomeKey:(NSNotification *)aNotification
>
> What I do want to know is which window had the focus before my window
> gets the focus. How can I do that?

I tried

    NSArray * arr=[[NSApplication sharedApplication] orderedWindows];
    NSLog(@"%i", [arr count]); //always 1
    myWndHadFocus=[arr objectAtIndex:0];
   
   
My programm: no window, only a NSStatusitem. myWndHadFocus is now always my
Statusitem :-( (btw. its funny to make a [myWndHadFocus miniaturize:self];
then).

Am I on the wrong way?

Bye - Robert
   
Simon Slavin - 26 Nov 2004 17:23 GMT
On 24/11/2004, Robert W. Kuhn wrote in message
<slrncq92qu.4hr.robert.w.kuhn@powermac.vermtech.de>:

> I have a windowcontroller and coded a
> - (void)windowDidBecomeKey:(NSNotification *)aNotification
>
> What I do want to know is which window had the focus before my window
> gets the focus. How can I do that?

Two possibilities:

1) Walk the window list and find which window is second from
  front.

2) Set up notifications for your other windows and
  note which became key (or resigned key) most recently.

Simon.
Signature

Using pre-release version of newsreader.
Please tell me if it does weird things.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.