1
votes

Now I drag a file to the app icon in the dock, this app is based on document . I found that no little image on the left of window title after the app is run and the mainwindow is open . but when I drag a file to the dock icon before the app run and use this method to run the app , a little image on the left of window title to show the file ,just like the xcode etc. Now I want to show the little image both way or not to show the little image both way , How to do ? I think that it maybe the window property based on document , but I don't know how to fix it ? Thanks!alt text http:///Users/jinxin/Desktop/Mydocument.png


I used the [mainWindow setTitle:tmp];, but icon still appear. when I used setTitleWithRepresentedFilename: I found that both icon and window title name both are modify, in the document class I overload the -(void)displayName; so I want to the window title is fixed anytime.

4

4 Answers

2
votes

If you just use -setTitle:, no icon. If you use -setTitleWithRepresentedFilename: you get the icon.

2
votes

OK, I found the result:

1.

[[window standardWindowButton:NSWindowDocumentIconButton] setImage:image]

2.

- (BOOL)window:(NSWindow *)sender shouldPopUpDocumentPathMenu:(NSMenu *)titleMenu
{
    return NO;
}
1
votes

From the Cocoa docs for NSWindow (under representedURL):

[[window standardWindowButton:NSWindowDocumentIconButton] setImage:image]

Maybe setting it to nil will do the trick.

0
votes

I tried all the answers above but they didn't work. This worked for me in Mavericks:

How to hide file icon in window titlebar of NSDocument