I would like to implement a dialog in my App that behaves like the New-File-Dialog in Xcode. Here is an image.
It must
docks to the toolbar
allow me to set a custom view
Is it possible to place NSTextFields in there and return/access their values, when the user klicks the ok button?
I know that the e.g. NSSavePanel behaves similar but I don't find anything for raping it like at. You can set just a view for distributing a save-action.
Best regards
You can implement this using sheets. You should refer Sheet Programming Topics.
Related
My app has all different kind of NSViews, including NSTabView, NSButton, NSTextField, NSPopupButton and so on.
I would like to change all display text to a certain font and with certain font style.
is there anyway to set the default font and font style in cocoa app?
I have tried:
How to loop through subviews in order to get the text of NSTextViews
however it doesn't work with NSTabView and NSButton.
I think that there must be an easy to do so, it's just I don't know what it is.
Please advise.
There isn't a built in way to do this (ie. by setting a key in Info.plist). You really do need to go through all the controls in your app, one way or another, and set a custom font for them. There are a few possible approaches. One is to use a custom subclass for all the controls for which you need to use a custom font. The subclass can be really minimal, it just needs to set the correct font upon initialization, possibly preserving other font attributes (size, color, etc.) setup in Interface Builder. Another option is to do as you've suggested and go through each subview in your app, check to see if it responds to -setFont:, and set your custom font if it does. I've used the first approach (subclass) with good success.
I would like to programmatically Add a UIScrollView in a UIAlertView.
I found a way to do that but I was not successful in adding text to this UIScrollView (using the same code as in here: https://www.youtube.com/watch?v=4SG0CAAl5u0).
is there an alternative to do that? the text I have is very long and I need people to be able to scroll but without being able to edit it.
I know that the Apple user interface guideline does not recommend long text in alerts (although detecting WiFi networks does that) but I have no choice but doing it
If you add a large text in UIAlertView it automatically becomes scrollable.
You don't have to do any thing to make it scrollable.
Here is a control on github that has a tabelView inside it. If you need to customize beyond what Inder suggests, you might want to look at the code and replace the tableView with a scrollView.
Also, there are other controls at cocoacontrols.com that might help you directly or give you some ideas.
I have seen that in Cocoa I can create a custom view using drawing primitives which allows me to draw what I like but at a very low level.
Instead I'd like to create custom widgets using a combination of existing controls. For example:
I'd like to create a table with images and combobox in cells
I'd like to create a custom widget wich is a combination of several (for example a list, a button and combobox)
How can I approach this problem ?
Secondly a typical cocoa developer uses external controls? Is there a repository or a list of interesting external custom controls (commercial or free) ?
I'd like to create a table with images and combobox in cells
There already exists NSImageCell and NSComboBoxCell. Are you sure you need to do anything different?
If the problem is that you want an image and a combo box in the same cell, you will have to subclass NSCell. Currently table views can only contain cells, not views, which makes your life harder (as understanding how cell drawing works is more difficult). That will change in Lion, however, so if you can wait until then, this will become easier!
I'd like to create a custom widget wich is a combination of several (for example a list, a button and combobox)
How is your custom widget different to just placing those three things in the same view?
You could write your own NSView subclass. When it's created, it should create a list, a button and a combobox and add them as subviews to itself. Your NSView subclass should handle the logic of keeping them in sync or doing whatever it is you want them to do. Then, to use this combination control in Interface Builder, you place a Custom View and set its class (rightmost tab of the inspector) to your NSView subclass.
BTW, on a tangent, are you sure you mean combobox? Loads of people coming from Windows get this one wrong. A combobox is a combination of a menu and a text field: it allows the user to enter custom text that is not in the menu. If you just want a dropdown menu of choices (and the user can't enter a custom one), you use an NSPopupButton.
Secondly a typical cocoa developer uses external controls?
Yes, sometimes. Things like BWToolkit can be very useful. There's a lot more that are just floating around mailing lists as code snippets, rather than being cleaned up and put in a library. Search for what you need to do!
How can I remove & show new UI controls at one place in mac application.
I want to have some layout at one place..which will be shown in different conditions.
I am new to the Xcode & objective c.
Please help
Based on your comment, it sounds like you want something along the lines of a wizard. For that, I'd suggest grouping your forms into an NSTabView. You can disable the tabs, and call one of the various tab selection methods instead. Have a look at Apple's Introduction to Tab Views for more.
See NSView's -replaceSubview:with:
I found this example pretty helpful. He describes a good way to set up your related views. You can always add the animation later once you get the basics down.
I am creating a Cocoa Application for Mac OS 10.6 >, and I want to hide the toolbar of an NSWindow automatically when it is not in use for at least 30 seconds.
I think this can be done with NSTimers, but I'm not familiar with them and I don't know how I can implement this.
Another problem is that both the NSToolbarDelegate and NSWindowDelegate protocols don't have delegate methods like toolbarDidShow:
Can anyone point me in the right direction? Thanks.
PS. This is not to punish the user, but rather give the user a cleaner window (the window consist of only a toolbar for color and font and a text-view).
PPS. Can the hide-toolbar-animation lead into a problem with the cursor while the user is typing?
I think this can be done with NSTimers, but I'm not familiar with them and I don't know how I can implement this.
The Timer Programming Guide might help you here. It's easy enough to show and hide the toolbar, use -setVisible:. Also, -isVisible can be used to determine the visibility of the toolbar.