How to set localized show / hide buttons in NSOutlineView

I have an NSOutlineView in my application. This function

-(BOOL)outlineView:(NSOutlineView*)outlineView isGroupItem:(id)item 

sets some elements in outlineView as the root of the group (if the function returns YES) + adds the show / hide buttons at the end of the cell to expand / collapse the contents of this group, but this button is written in English. I am from Belarus, so I want to show / hide words written in my language. Finder writes in my language, so I think it’s possible to set a localized style for it. How can i do this?

SOLVE: Mac OS does this on its own when choosing the localization of the .nib file that contains NSOutineView

+4
source share
1 answer

The official way to get the localized show / hide button (as well as the expand button) is now documented in the NSOutlineView class reference.

 let showHideButton = outlineView.makeViewWithIdentifier(NSOutlineViewShowHideButtonKey, owner: outlineView.delegate()) as? NSButton 

It is important to note that the state property of the button controls the Hide / Show header, which by default is not synchronized with the state of NSOutlineView:

  • NSOnState = "Hide"
  • NSOffState = "Show"

NSOutlineViewDisclosureButtonKey Normal triangle disclosure button.

NSOutlineViewShowHideButtonKey Show / Hide Button.

The outline view creates these buttons, invoking its inherited makeViewWithIdentifier:owner: passing the key as an identifier and a delegate as an owner.

These keys are backward compatible with OS X v10.7, however the character is not exported to version 10.9, but the string value (@ "NSOutlineViewDisclosureButtonKey").

0
source

Source: https://habr.com/ru/post/1387967/


All Articles