Search code examples
objective-cmacosinternationalizationright-to-left

Set right-to-left orientation for NSButtonCell


Right-to-left (RTL) languages expect that the checkbox/radiobutton is to the right of the text in checkbox/radiobutton groups and that the text is right aligned.

When I set right-to-left language (Testing Your Internationalized App) most of the elements in the interface are respecting this setting, but checkboxes and radiobuttons are still incorrectly aligned.

I tried to explicitly set the direction by calling [cell setUserInterfaceLayoutDirection:NSUserInterfaceLayoutDirectionRightToLeft] but that does not seem to have any effect even though it is recommended in this mailing list.

Building a "reverse column order" solution (as recommended for NSTable here) for the NSMatrix require some more work since I use a single column NSMatrix with NSButtonCell.

Related questions:

What is the recommended way to adapt checkboxes and radiobutton in NSMatrix:es to RTL languages?


Solution

  • The solution is to manually set the "image" position and text alignment.

    [cell setImagePosition:NSImageRight];
    [cell setAlignment:NSRightTextAlignment];