I have an NSSegmentedControl with the textured rounded style, and with the selection mode set to 'any'. The problem is that it is treating it like select none. When I switch the style to capsule, it works correctly. I am using this in a toolbar, although I have tested this in a view (on two different computers) as well and it behaves the same way.
Thanks for the help
I've just realized this is a function of the rounded textured style. As of 10.5 (when I believe this was introduced), selection on this style of segmented control is indicated by a template image "glowing," not by a "pressed in" appearance.
There's an example showing a 3-segment control in the configuration you're asking about, each with NSLockLockedTemplate as its image. The "selected" states are, left to right, true, false, true.
So, not a bug, but a feature.
Related
ALL,
NSSmallControlSize page has following explanation:
This constant is for controls that cannot be resized in one direction,
such as push buttons, radio buttons, checkboxes, sliders, scroll bars,
pop-up buttons, tabs, and progress indicators. You should use a small
system font with a small control.
Is there any way to set the size for other controls? Namely NSComboBox.
Unfortunately the documentation is not talking about that. It's not even mentioning if it is at all possible.
TIA!
As the page describes, the constant is for controls that cannot be resized in one direction. Combo boxes, like the listed controls, cannot be resized vertically. Therefore it makes sense that the constant would apply to combo boxes.
This can be quickly verified by creating a combo box in Interface Builder, clicking on the Size inspector, and setting its size to Small. Since this works, we can conclude that the small size is compatible with combo boxes.
I'm trying to create an application that would be as standard as possible in terms of style.
An image is worth a thousand words: I can't figure out how to make my buttons the same size as in Apple's programs such as Safari or Finder.
As you can see, the sizing I've set in interface builder don't seem to match the size the buttons get when I run the app, but maybe that part doesn't speak in pixels but in points or something? Also, textured rounded button has only width editable, but not height.
In this case, these are NSButtons, but I guess I'll have a similar problem with other control types...
I found it out! The problem was with neither of these two parts outlined in the screenshot, but in the "Toolbar" item, higher in the hierarchy.
There is a Size attribute in the Attributes inspector which defaults to Small, but you can set it to Regular instead, and then the buttons get the same sizing as in Finder and all.
Some of the color selection buttons in the Xcode details panels are a NSPopupButton with a color well. It looks something like a segmented control/popup button.
Placing a standard color well and standard popup button next to each other doesn't have the same look. Also, the menu wouldn't cover the color well in this case. The popup image (two triangles) is not readily available for a custom control either.
Anyone tried to make a similar control before? Any hints on how to make it?
I'm writing an OS X app and have a problem with font smoothing in separate window.
I have a text field where you put text and suggestion window which pops up with a list of suggestions according to what you wrote. I'm using View-cell based NSTableView to display those suggestions and SFBPopoverWindowController to display it as a "popup" window (tried other classes with the same effect). When rows are first drawn they look fine but after I select them (keyboard or mouse) the font changes it's weight. It's only visual - like you would change smoothing method on the font, not it's bold setting.
"Music note" is the selected cell here
What's even more strange is that after I hide and show the window 3 times everything works fine from that point on.
Again - "Music note" is the selected cell.
The selection is done by overwriting NSTableRowView class and its drawSelectionInRect: method but I tried with drawing everything inside custom NSTableCellView class and it didn't help. The text is standard NSTextField - nothing's changed there.
The SFBPopoverWindow (and it's controller) are created once and reused with styleMask NSBorderlessWindowMask, backing NSBackingStoreBuffered, defer set to YES. The only change in SFBPopoverWindowController I made was to turn off window becoming key window but it doesn't change anything.
It might be related to the way a table view draws it's selected cells (setSelectionHightLightStyle:). Try to set the style to None/ NSTableViewSelectionHighlightStyleNone in your code or IB / Storyboard-file and draw the selection yourself (in a NSTableRowView subclass).
Background: When you use NSTableViewSelectionHighlightStyleRegular or NSTableViewSelectionHighlightStyleSourceList the table view assumes that you use the standard selection behaviour and appearance and does some magic to support that.
==========
UPDATE
==========
My previous answer is still valid but since it only describes the problem and hints at a workaround, I wanted to add a real solution. If you want to use NSTableViewSelectionHighlightStyleRegular for your table view (with custom font and colors), you need a way to 'disable' the system magic that comes into place once your row is highlighted. One proposed solution is to decline the first responder status. It has a lot of drawbacks and isn't a good solution at all.
So, let's have a closer look at the system 'magic' that kicks in as soon as the row will be highlighted: NSTableRowView has a property interiorBackgroundStyle that is – according to the documentation – 'an indication of how the subviews should draw'. Furthermore 'This value is dynamically computed based on the set of properties set for the NSTableRowView. Subclassers can override this value when they draw differently based on the currently displayed properties. This method can also be called to determine what color a subview should use, or alternatively, NSControls can have the -backgroundStyle set on their cell to this value.'
I assume that this style will be handed down the subview hierarchy and causes your text fields to look odd. The system assumes that a highlighted cell has a dark background and changes the interiorBackgroundStyle to dark. Other controls try to adapt accordingly.
I think there are two solutions to this problem:
1) Override interiorBackgroundStyle in your NSTableRowView subclass and return the style that fits your interface (in my case it's .light because my highlight color is a very bright blue). This worked for me.
2) If changing the whole style is a bit too much because you only want certain elements to not change their style, you may only need to adjust these subclasses. I haven't tried this yet.
I have a square NSButton and an Image the same size of the button. I set the image to the button, turned off bordered and set scaling to none. Then the image seems smaller than the button. If I set scaling to axes independent, the image can fill the all button. But is set button enable to false. The button disappeared. Does anyone know what's wrong with it?
Well... Your description, IMHO, is a bit confused! Anyway, for what I understood, you're having problem with Xcode.
You have to set the scaling because the button is always a bit larger than its content, because of the border (even if you turn off its borders, it will still be rendered with a small invisible border). For an unknown reasons, setting to Axes Independently solves this problem and resizes the image in the correct way (this works in any kind of NSControl you can use).
I cannot figure out how enabling or disabling the button can influences its visibility. Are you sure you're not using the "Hidden" property instead of the "Enabled" one?
[myButton setHidden:YES]
This will make the button transparent and insensible to clicks.
[myButton setEnabled:NO]
This will act on the answer to user clicks (and it's what you're looking for). Is your image mainly grey? Disabling the button will make the button gray, and this could make the image invisible...