NSButton will automatically enforce image position NSImageOver when localised

Originator:jum
Number:rdar://37025975 Date Originated:2018-01-30
Status:Open Resolved:Duplicate/25860221
Product:macOS / SDK Product Version:
Classification:Other bug Reproducible:always
 
Summary:
When a XIB or storyboard contains an NSButton that has a title, but the button's image position is set to "NSImageOnly" in the XIB, adding a localized strings file for that XIB (base localisation + strings file) will enforce the button's imagePosition to NSImageOver. Apparently, this happens when -[NSButton setTitle:] is called with the localized title, at which point NSButton will change the image position to NSImageOver.
This is unfortunate, since it won't allow buttons to have imagePosition NSImageOnly initially but still have localized titles (without having to manually overwrite the image position change in viewDidLoad, etc.)

Steps to Reproduce:
- Open, build and run the attached sample app project "NSButtonImagePositionBug.xcodeproj"
- check the button in the center of the main window

Expected Results:
- since button properties in XIB are specified as image position "NSImageOnly", the button should just display the image, but not the button title "Button"

Actual Results:
- button title "Button" is overlayed over the button image

Version/Build:
macOS 10.12 and macOS 10.13 (have not yet tried other versions of macOS)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!