The Windows version of the PureBasic compiler accepts #PB_Text_Center or #PB_Text_Right flags to justify the text to the centre or right position respectively - much like the TextGadget counterpart - although this behaviour seems to be undocumented.
This fails under OSX though. i.e.,
applying the #PB_Text_Center flag leaves justification as left-hand and makes the StringGadget un-selectable whereas the #PB_Text_Right flag still leaves the justification as left-hand and puts the StringGadget into 'password' mode.
Can anyone suggest how to make the StringGadget display right-justification or - more critically - centre-justification?
TIA
Dave
How do I centre text in StringGadget (OSX)?
Re: How do I centre text in StringGadget (OSX)?
try
- the Editor gadget doesn't have any checkboxes for alignment
- the String gadget doesn't have any checkboxes for alignment
- the Text/label gadget does have alignment, and when i tried the Centered one it worked fine
so I'm not too sure which OSX controls actually support alignments, but that CocoaMessage seemed fine last time i tested it!
Code: Select all
CocoaMessage(0, GadgetID(mygadget), "setAlignment:", 2)
btw i just had a look at those controls in the Form Designer on 5.42LTS x64 OSX ...This fails under OSX though. i.e.,
applying the #PB_Text_Center flag leaves justification as left-hand and makes the StringGadget un-selectable whereas the #PB_Text_Right flag still leaves the justification as left-hand and puts the StringGadget into 'password' mode.
- the Editor gadget doesn't have any checkboxes for alignment
- the String gadget doesn't have any checkboxes for alignment
- the Text/label gadget does have alignment, and when i tried the Centered one it worked fine
so I'm not too sure which OSX controls actually support alignments, but that CocoaMessage seemed fine last time i tested it!
Re: How do I centre text in StringGadget (OSX)?
Thanks for that Keya, wonderful stuff.
ATB
Dave
ATB
Dave
Re: How do I centre text in StringGadget (OSX)?
http://www.purebasic.fr/english/viewtop ... 31#p390031
Code: Select all
;set string gadget to right-justified
#NSRightTextAlignment = 1 ; for right align string gadget
CocoaMessage(0,GadgetID(2),"setAlignment:", #NSRightTextAlignment)
MacBook Pro-M1 (2021), Sonoma 14.3.1 (CLT 15.3), PB 6.10b7 M1
Re: How do I centre text in StringGadget (OSX)?
You may also take a look into this cross-platform example which demonstrates how to right-justify text in a StringGadget and which is also listed in my collection of cross-platform examples.
-
- Enthusiast
- Posts: 125
- Joined: Wed May 20, 2020 5:19 pm
- Location: The 3rd planet in the Solar System
- Contact:
Re: How do I centre text in StringGadget (OSX)?
Hello.
Tnx for the trick.
But on latest Mac OS
Tnx for the trick.
But on latest Mac OS
Code: Select all
CocoaMessage(0, GadgetID(mygadget), "setAlignment:", 1) ; - for Center align.
CocoaMessage(0, GadgetID(mygadget), "setAlignment:", 2) ; - for right align.
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.