I am going to build an app that I want to contain in separate categories and want to display them in their own window by clicking on a Menu Button. This will be something similar to TinkerTool app, or VLC’s Preferences Window.
Could anyone suggest a way to begin such an app in code or in Bindings please.
Yes, that’s how you do it if you want the windows in separate .xib files. Indeed, if you’re using Objective-C, that’s very much the recommended way to go.
In ASObjC, I think it adds a level of complexity that’s probably not justified for simpler jobs. For more complex jobs it is – but then I’d argue that more complex jobs are usually better off written in Objective-C in the first place.
( You will notice that the tool bar acts like it does when you customize a tool bar )
Now add as many Image Tool bar items as you need to the NSToolbar. ( this makes sure they are clean )
Select each Image Tool bar item. and Set it up using it’s attributes inspector .
Set its Image.
Check ‘Selectable’ – This gives it the depressed look when it is selected. Like system preferences and VLC.
Drag the Image Tool bar item into the Default Toolbar Items. This will make them show when running.
Click the done button and the customise sheet will close.
Because you do not want the user to customise the Toolbar and you want it to act like a normal preference type toolbar.
Uncheck ‘Customizable’ in it’s attributes inspector.
Now drag a NSTabView onto your window.
Set it to ‘Tabless’ in it’s attributes inspector.
Size it so it fills the window and top edge is under the NSToolBar
Connect the NSTabView as an outlet .
Place you other UI in each Tab as needed.
You now need each Image Tool bar item to be connected to an Action. Either one each or a single one that checks the sender and acts accordingly.
For example a single action per Image Tool bar item.
One thing you should also do is for each Image Tool bar item you should set it’s identifier in it’s attributes inspector.
This will allow you to set which tool bar is selected when the window is open. Otherwise the default tab will be showing but the Tool bar item will not be selected.
You can set the selected tool bar item in for example the AwakeFromNib or when the window is opened using:
remember to connect the NSTool bar with an outlet.
This also assumes the default Tab is the first tab.
If the tab was the second Tab the you would need to make sure the selected tool bar item matches that.
This all is in Objective-c, but should be easy to convert.
I should add that I have only just figured all of this out to answer your question as it was also of interest to me. I wish I had looked at the before because it is actually relatively easy compared to all the messing around to get this effect I have done in the past. But I guess my learning curve as allowed me to see what needs to be done now where as before I could not.