• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Binding InfoPanel to currentDocument
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding InfoPanel to currentDocument


  • Subject: Re: Binding InfoPanel to currentDocument
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Fri, 26 Oct 2012 15:52:50 +0700

On 26 Oct 2012, at 01:11, Seth Willits <email@hidden> wrote:

> On Oct 25, 2012, at 4:36 AM, Gerriet M. Denkmann wrote:
>
>> This works, but I have a strong feeling that there is a very obvious better solution which I somehow cannot see.
>
>
> There actually isn't an obvious solution.

Strange.
I thought that having some InfoPanel which shows data of the current NSDocument would be a fairly common scenario.
But anyway.

I decided to follow your suggestions.

My app delegate now has:
@property (strong) GmdDocument *currentDocument;

In applicationDidFinishLaunching: it registers for NSWindowDidBecomeMainNotification and NSWindowWillCloseNotification (not for NSWindowDidResignMainNotification because I want my InfoPanel to keep it's data when some other app becomes active).

The notification method is:

- (void)someWindowChanged: (NSNotification *)noti
{
	NSWindow *window = [ noti object ];

	if ( ![ window isMemberOfClass: [ NSWindow class ] ] ) return;	//	ignore non-Windows

	NSWindowController *windowController = [ window windowController ];
	if ( windowController == nil ) return;	//	ignore strange windows

	GmdDocument *document = [ windowController document ];
	if ( ![ document isKindOfClass: [ GmdDocument class ] ] ) return;	//	ignore strange documents

	if ( [ [ noti name ] isEqualToString: NSWindowWillCloseNotification ] ) document = nil;

	self.currentDocument = document;
}

The InfoPanel binds it's things through File's Owner: currentDocument.

Seems to work perfectly now.

Thanks a lot for your help!


Kind regards,

Gerriet.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Binding InfoPanel to currentDocument
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: App rejection due to app-sandboxing invalid entitlement
  • Next by Date: Re: Binding InfoPanel to currentDocument
  • Previous by thread: Re: Binding InfoPanel to currentDocument
  • Next by thread: Re: Binding InfoPanel to currentDocument
  • Index(es):
    • Date
    • Thread