• 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 window titles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: binding window titles


  • Subject: Re: binding window titles
  • From: Jeff Gilbert <email@hidden>
  • Date: Sun, 5 Jun 2005 16:29:59 -0500

On Jun 5, 2005, at 3:50 PM, Lee Morgan wrote:

On Jun 5, 2005, at 2:16 PM, Jeff Gilbert wrote:


After some more digging, I discovered the following...

I set a breakpoint on [NSWindow setTitle] and discovered that the window title was properly set to the bound value as soon as the window was unarchived. However, when I later called [NSWindowController showWindow], the call stack looks like the following:

-[NSWindowController windowTitleForDocumentDisplayName:]
-[NSWindowController synchronizeWindowTitleWithDocumentName]
-[NSWindowController window]
-[NSWindowController showWindow:]

So, it seems that showing the window is hardcoded to call windowTitleForDocumentDisplayName and does not respect the fact that the window title may already be set via a binding. So, I'll probably file a bug/support request to see if this is the intended behavior.


A few things that may help...
Best I know / can tell windowTitleForDocumentDisplayName only sets the window's title to "Untitled" if it doesn't have a bound value. I've never see it work another way, nor have I seen it documented otherwise.
(*hint*) synchronizeWindowTitleWithDocumentName will cause a problem if you have a document associated with your window controller, that is if your document isn't NULL! If you have a document object set for the window controller then synchronizeWindowTitleWithDocumentName will set the window's title to either [[windowController document] fileName] or "Untitled" if it returns nil. Best guess - this is your problem, since it doesn't respect the bound value here.


With that said you could bind your document's fileName to the value your want instead of the window, or
You could use [[windowController window] makeKeyAndOrderFront:self]; which doesn't synchronize the window's title with it's document.

Interesting...I will look at makeKeyAndOrderFront.

In this case, the window is not the "primary" document window, but a detail view of one of the objects in the document. I have several different types of detail windows, each one with a different pattern for the window title. So setting the document filename may not be appropriate in this case.

Oh, and of course as I'm sure you know setTitle: will NOT change your bound value to whatever you provide, but rather only change the value of the window's title - so if your using bindings you probably shouldn't use setTitle: However as you were debugging I'm sure you already know this.

Yes, I was just setting a breakpoint on setTitle: to catch every time the window title was updated, as the title binding calls setTitle: to set the window title. This is how I determined that the title binding actually was being correctly set when the window was first created. It was then overwritten by the document title after the window was shown.


Anyways, this is now moot as I realized that the binding for displayPatternTitle1 is only available in 10.4, and for now I still need to support 10.3.


Not really sure where you got that idea from. displayPatternTitle (...) is available in 10.3 and beyond - at least doing a Compatibility Check in IB doesn't show any compatibility problems with it and 10.3

The Cocoa Bindings Reference for NSWindow states that displayPatternTitle1 is available in Mac OS X 10.4 and later. It seems that displayPatternTitle1 is available in 10.3 for other controls (e.g. NSTextField). To find the reference, do a full-text search in the Xcode documentation window for "NSWindow". The Cocoa Bindings Reference should be the first result.



My current solution, is to programatically set a KVO observation for the interested object property and in the notification I call [self synchronizeWindowTitleWithDocumentName] and just use windowTitleForDocumentDisplayName: to provide the window title.


Thanks for all your assistance,
Jeff
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: binding window titles
      • From: Lee Morgan <email@hidden>
References: 
 >binding window titles (From: Jeff Gilbert <email@hidden>)
 >Re: binding window titles (From: Jeff Gilbert <email@hidden>)
 >Re: binding window titles (From: Lee Morgan <email@hidden>)

  • Prev by Date: Re: binding window titles
  • Next by Date: Re: binding window titles
  • Previous by thread: Re: binding window titles
  • Next by thread: Re: binding window titles
  • Index(es):
    • Date
    • Thread