I've looked through the NSDocuments docs but can't see any methods for controlling whether window positions are saved. But if I move a window before quitting, that position overrides the window position set in IB.
In your XIB file, select the window. You should see the options on the right of the screen.
The "Restorable" check box should be what you're looking for. I haven't tried this in a document based application but I'm pretty sure it's the same here.
Related
I am in the process of creating a small image editor.
What I aim, is to create a window with transparent titlebar, but not what contains inside the window.
I have check HUD Window, but it's really is a panel, not a window. And I am missing the regular close,maximize and minimize button.
Is there anyway to create such window?
Or can we modify HUD to hold regular close,max and min button?
Thanks so much in advance!
Eko
Use a standard borderless window approach and provide a content view that draws something. Even if the content view's bounds rect is just filled with [NSColor whiteColor].
Update: Re-reading, I see you seem to be asking for just a transparent title bare but still with the window controls. See this StackOverflow question for an approach at customizing a window's title bar. Careful, though - I'm not sure this would be accepted into the App Store. Best to have a backup plan in case it's not.
Here is what I found that match to what I want : window trasparency
The trick is making the main window transparent, but not the content by creating a special view for this.
How do I go about adding/removing the window border after it has been created? the window was already designed in interface builder and I would prefer to avoid writing the window purely in code as I am still a long ways before i can say i am experienced with objective-c/cocoa.
Example Program:
a single window with the border initially, a button on it. If you click the button once it makes the boarder disappear and if you click it again then the boarder reappears.
Thanks
As far as I can tell, you can't. You might be able to fake it by taking the content view out of one window and making it be the content view of another window.
Hey all, I'm pretty new to Cocoa and XCode, so I'm sorry if this is a dumb question.
How would I go about checking which window is in focus?
Additionally how would I go about checking if a certain window is in focus, if this is not the same as the previous solution.
Thanks for the help.
There are actually two forms of “focus”:
The window that has the active appearance (colored/dark gray stoplight, black text in title bar, undimmed proxy icon, etc.) is the main window.
The window that receives key events is the key window.
Consider a document window with an Inspector panel. If the user is editing some text in a field in the Inspector, then the document window may be main, but the Inspector panel is key.
To get the key window or the main window, ask the shared NSApplication instance. And, as TechZen noted, you can ask a window both whether it is key and whether it is main.
You looking for 'keyWindow'. It's a property of both NSWindow and NSApplication. It's a bool in the former and a NSWindow instances in the latter.
Each time I create any type of cocoa project (document-based, with core-data and/or spotlight importer) and open MainMenu.xib, I get a warning sign in bottom right object palette window corner saying that window is out of screen bounds. Why is this so? Any remedy?
I get a warning sign in bottom right object palette window corner saying that window is out of screen bounds. Why is this so?
Because the window falls at least partially outside the screen bounds.
Any remedy?
Put it completely within the screen bounds. Select the window and use the Content Size & Position section of the Size (⌘3) inspector to move it.
Simply dragging the window by its title bar will not help, since that position is only for display in IB; it doesn't affect the window that will appear in your app, which is what the warning is about. You need to use the Size inspector.
I once had a similar problem when I had a second monitor connected to my MBP.
When the second monitor was set to a low resolution (I think it was 1024x768), Interface Builder came up with that particular warning. (Although the window did fit between the main menu and the Dock).
Is there a way to preserve window position in Interface Builder? Every time I reopen a nib file, the MainWindow.xib window finds its way back to the top left of the screen, behind the window containing the interface I'm laying out. Moving it back to where I had it before every time is starting to get on my nerves. Seems like there should be an easy way to do this, but if there is I haven't been able to find it.
Thanks!
Interface Builder does not save window location/size on a per-nib basis, but it does automatically remember the size and position of the last nib window and uses that when opening future nib files. For example, if I open up nib file A, change its window's position, and then quit IB, then open up nib file B, its nib window shows up with the same location/size I had set for nib file A.
However, it appears that Interface Builder also cascades multiple windows down and to the right slightly when you open them up, so that a second nib file's window doesn't appear directly on top of one that's already open - makes sense. The problem appears to be that if you have a nib window positioned all the way at the bottom of the screen, so there's not enough room to open the next nib window, it results in the window being placed all the way at the top of the screen. Then of course once that happens, IB remembers that window position as the default, so subsequent windows also get opened at the top of the screen.
So, the "solution" is a) file an enhancement request on Bug Reporter to remember per-nib window positions :-), and b) in the meantime be careful about positioning your windows too close to the bottom of the screen.