I am currently instantiating an NSMatrix w/ NSButtonCell subclasses through IB
I use the identity inspector to change the Tool Tip property
But the tooltip doesn't show on the button cell.
If I set a tooltip on the NSMatrix object, a tooltip still doesn't show
If I add an NSButton to the same view, and add a tooltip to that, it does show
Why won't my tooltips on NSMatrix or NSButtonCell show?
I don't know why it can not be set in the Interface Builder (It seems like a long standing issue), but you can set them at least programmatically.
[self.matrix setToolTip:#"Tooltip for first item" forCell:[self.matrix cellAtRow:0 column:0]];
[self.matrix setToolTip:#"Tooltip for second item" forCell:[self.matrix cellAtRow:1 column:0]];
Careful, if in InterfaceBuilder you click the button, you can add the tooltip to the button, and the class displayed under "Custom Class", top right, is NSButton. But, if you click the button again, as you do while selecting stuff in xcode, what is selected is the NSButtonCell, which appears to have a separate tooltip. If you're not careful you add your tooltip to the NSButtonCell instead of the NSButton, and it won't show in your running application.
So, the problem may be that you have clicked the button one more time in IB, and you thought to enter the tooltip for the NSButton, but you didn't.
Personally I think it may be a bug, why would you want to add a tooltip for the button cell?
Related
How do you set the menuFormRepresentation for an NSToolbarItem in Interface Builder?
I was trying to transition from programmatically constructed window toolbars to ones created entirely in IB (with an ultimate goal of easier localization).
I'm also transitioning from image-based items to view-based item to support NSButton and NSSegmentedControl items.
My first step was to just modify the existing code to create view-based toolbar items instead of image items. That works just fine.
My next step was to rip out all of the code and use just IB (Xcode 9.2) to create the toolbar and toolbar items. Most of it works, but the NSButton items don't get enabled or disabled properly.
When I wrote the code, I had to create NSMenuItem (or NSMenu) objects for each toolbar item and use that to set the item's menuFormRepresentation property. According to the documentation "Setting a Toolbar Item’s Representation", if you don't do this a view-based item (a) won't get validated automatically and (b) will not appear in the text-only version of the toolbar or the overflow menu.
I've looked everywhere in IB I can think of, but there's no outlet, property, or attribute where you can set the item's menuFormRepresentation property. I've also tried dragging and dropping a menu item on the toolbar item; nothing happens.
The documentation for "Creating a Toolbar in Interface Builder" doesn't make any mention of what to do about menuFormRepresentation, yet without it the item is functionally crippled.
Is this a huge hole in IB or am I missing something?
I'm trying to make a native NSButton object in IB. When I select Accessory as a Button Type, the title disappears. When I try to write the title, the button is not resizing and the triangle keeps disappearing.
How to make a NSButton with text and down-facing accessory triangle on the right indicating this is something you can click and will popover?
Maybe NSPopUpButton is what you're looking for.
I'm trying to make my first Cocoa app (previously I was making iOS apps) and what I wish to do for my custom view is make it's title clickable with indicator (accessory) triangle facing down.
Clicking the title would open a popup/menu with my items.
How is that doneable in Cocoa?
Rdelmar's answer is probably the easiest way to go, but may not do exactly what you might want to do (which is replace the actual title with a pop up item, instead of having a popup button under the title in the toolbar area). With respect to functionality your application will probably work just as well using the toolbar.
If, however, you truly want to replace the actual title, the means of going about this would be to set the NSWindow title text to #"" to hide it, and redraw it by sticking in your own view.
[[[theWindow contentView] superview] addSubview:theSubview];
This basically tells the superview of the main content view to add another subview (direct "translation" from the code), and you'll have to tinker with the frame of this new subview to have it be positioned where the title should be positioned (as now it's free to be placed anywhere in the window frame, including on top of the title bar, as opposed to simply inside the content view).
theSubview can be your popup button, or whatever you want, and you'll also probably have to custom draw the popup button to match the original drawing of the window title.
You can do this by adding a toolbar to your window in IB. Once, you add the toolbar, you can double click on it to open the customizer view of it. Drag a popup button into the Allowable Toolbar Items area and after it is inserted there you can drag it into the bottom area which shows the layout of the toolbar -- you can also drag out any of the default items there that you don't want.
I need to display/show a Picker when a user taps on a textfield, I mean, it should appear a picker instead of a keyboard. Also, some sort of "done" button above the picker so the user clicks on it and the value from the picker is copied to the textfield and the picker is hidden again.
I've checked many tutorials from the web but haven't found anyone that can really help me.
I found a tutorial that pointed me in the right direction but I'm still missing to disappear the keyboard when clicking on the textfield.
Dismissing UIPickerView with Done button on UIToolBar by #slev
Any ideas?
If you're not targeting iOS versions older than 3.2, it's easy. You can either assign the UIPickerView as the inputView property of the UITextField and the UIToolbar containing the 'done' button as the inputAccessoryView, or you could make a single UIView that has both the picker and the toolbar as subviews and assign that as the intputView (and leave inputAccessoryView as nil). Either way, this will animate your picker in in place of the normal keyboard when the text field is activated.
More details on this are available in the documentation.
I have an NSToolbar set up in my app. It was created in IB. One of the toolbar items uses a spinner-style NSProgressIndicator as its view, the rest are images.
When the toolbar's customization sheet is showing, the spinner does not show in the sheet.
I initially thought that this was because the spinner's -displayedWhenStopped was set to NO. That's not the case: if I set it to YES, the spinner shows in the toolbar when active, but doesn't show in either the toolbar or the sheet when stopped.