How can I set title of button to 'bold', please

G’day

I’ve tried different permutations of trying to set the tile of a button to ‘bold’ and ‘plain’ with no success. The first ‘set’ below does not error, the second attempt does.

Any advice please?

Regards

Santa


on oldEmailChoiceListDefinerButtonSetter()
		try
			set p to 1
			set arrivalButton's style to plain
			set p to 2
			set mailboxNameButton's text style to plain
			set p to 3
			set subjectButton's style to plain
			set p to 4
			set senderButton's style to plain
			set p to 5
			 if my eMailsToChooseFromSortDefiner is arrivalButton's title then set arrivalButton's |text style| to bold
			set p to 6
			if my eMailsToChooseFromSortDefiner is mailboxNameButton's title then set mailboxNameButton's style to bold
			set p to 7
			if my eMailsToChooseFromSortDefiner is subjectButton's title then set subjectButton's style to bold
			set p to 8
			if my eMailsToChooseFromSortDefiner is senderButton's title then set senderButton's style to bold
		on error errmsg number errnum
			display dialog "oldEmailChoiceListDefinerButtonSetter " & errmsg & "error number " & errnum & " p = " & p as text giving up after 40
		end try
	end oldEmailChoiceListDefinerButtonSetter

Model: Late 2014 retina i7, Yosemite
AppleScript: 2.4
Browser: Safari 600.2.5
Operating System: Other

Don’t do it. Buttons aren’t meant to be bold; it’s breaching the UI guidelines.

G’day Shane

Guidelines are simply that, guides.

My situation is that I have a pop-up button which contains details of up to (user settable) 500 last incoming emails (just over 1 days worth on average).

Below it I have a row of four sorting buttons, ‘Arrival Order’, ‘Sender’, ‘Subject’, ‘Mailbox Name’ (which could be one of up to 6 mailboxes).

I need to visually display which sort button is presently active, and have resorted to using borderless titled buttons, with 3 white backgrounds, and the active button in grey.

I believe this is also breaching the guidelines, but who basically gives a damn. The guidelines don’t cover this situation, other than perhaps using horrible looking Radio Buttons. It’s just that my present choice looks darn ‘inelegant’, and I’d prefer a more subtle ‘bold text’ title.

But how? Anyone please?

Regards

Santa

Model: Late 2014 retina i7, Yosemite
AppleScript: 2.4
Browser: Safari 600.2.5
Operating System: Other

Users, mostly.

G’day

Whilst I probably went a bit overboard using ‘damn’, perhaps someone could suggest an alternative to white and gray buttons (which don’t look right without a border, and look a bit ‘dominating’), or radio buttons, please? Anyone?

If there’s no alternative, I’d still appreciate the method for setting a buttons text to ‘bold’, instead of using the following code…

Regards

Santa


on oldEmailChoiceListDefinerButtonSetter()
		try
			set whiteColor to current application's NSColor's whiteColor()
			set lightGrayColor to current application's NSColor's lightGrayColor()
			arrivalButton's cell's setBackgroundColor:whiteColor
			mailboxNameButton's cell's setBackgroundColor:whiteColor
			subjectButton's cell's setBackgroundColor:whiteColor
			senderButton's cell's setBackgroundColor:whiteColor
			if my eMailsToChooseFromSortDefiner as text is arrivalButton's title as text then arrivalButton's cell's setBackgroundColor:lightGrayColor
			if my eMailsToChooseFromSortDefiner as text is mailboxNameButton's title as text then mailboxNameButton's cell's setBackgroundColor:lightGrayColor
			if my eMailsToChooseFromSortDefiner as text is subjectButton's title as text then subjectButton's cell's setBackgroundColor:lightGrayColor
			if my eMailsToChooseFromSortDefiner as text is senderButton's title as text then senderButton's cell's setBackgroundColor:lightGrayColor
		on error errmsg number errnum
			display dialog "oldEmailChoiceListDefinerButtonSetter " & errmsg & "error number " & errnum as text giving up after 40
		end try
	end oldEmailChoiceListDefinerButtonSetter
	

Model: Late 2014 retina i7, Yosemite
AppleScript: 2.4
Browser: Safari 600.2.5
Operating System: Other

Hi,

two alternatives are the enable property and the keyEquivalent property of NSButton.
Setting the keyEquivalent property to return (“r”) makes the button the default button (blue color)

Have you considered using a NSSegmentedControl instead of NSButtons?

You mostly don’t set a font to bold, but there is another font which is the bold version.

To set a button title to bold you simply choose a font that is bold:

[button setFont:[NSFont fontWithName:@“Menlo-Bold” size:10]];

in ASObjC:

set theFont to NSFont's fontWithName:"Menlo-Bold" size:10
button's setFont:theFont

Thanks to all, especially DJ.

Regards

Santa

Model: Late 2014 retina i7, Yosemite
AppleScript: 2.4
Browser: Safari 600.2.5
Operating System: Other