DT create label right align and center align goofy

Hey, I just upgraded my computer to M1, MacOS to 12.01, and Script Debugger to 8.0.3

Now create label right and center align behavior is odd. Right align results in the longest line being right aligned and the shorter lines centered on the longest line.
Screen Shot 2021-12-25 at 7.20.10 AM

Center align results in the longest string being centered and the shorter lines right aligned with the longest line.
Screen Shot 2021-12-25 at 7.18.41 AM

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
use script "Dialog Toolkit Plus" version "1.1.2"

set accViewWidth to 300
set buttonList to {"Cancel", "Process"}
set leftLabel to "left line 1" & return & "left 2" & return & "left line three"
set rightLabel to "right line 1" & return & "right 2" & return & "right line three"

set {theButtons} to create buttons buttonList cancel button 1 default button length of buttonList with equal widths

set {newNameExampleLabel, theTop} to create label rightLabel bottom 0 left inset accViewWidth / 2 max width accViewWidth - accViewWidth / 2 aligns left aligned control size small size with multiline
set {newNameLabelLabel, theTop} to create label leftLabel bottom 0 left inset 0 max width accViewWidth / 2 aligns right aligned control size small size without multiline

set allControls to {newNameExampleLabel, newNameLabelLabel}
set {buttonName, controlsResults} to display enhanced window "Left block right aligned" acc view width accViewWidth acc view height theTop acc view controls allControls buttons theButtons giving up after 240 with align cancel button

I could work around this feature, if I know what triggered it. It would be great to have a fix. Thanks!

The issue is the value of the enum NSRightTextAlignment. It was defined in macOS as 2, but presumably by mistake, in iOS it was defined as 1. It seems newer versions of macOS, when running on Apple silicon, are now using the iOS value. It’s a bit of a mess.

The best solution is not to define the value in the script, and to use the newer enum, NSTextAlignmentRight. I’ll update the library accordingly, as soon as I can be sure it won’t fail under earlier versions of macOS.

1 Like