Superscript and Subscript in MobileLable

I’m trying to figure out how to include super/subscript in labels.
I would prefer to not have to create a custom control.
Any hints?

You at be able to get NSTextField and change attributed string value to use sub/superscript.
But I haven’t tried that with our plugins.

Chris, are you using iOSKit?

I might have a solution if you are.

I am.
Also it appears I can paste the desired string into the editor and it works.
But…… I think a lot of the characters aren’t available in subscript. I don’t understand why.
For example there is no subscript “b”.

I tried things like:

Dim a As NSAttributedStringMBS = NSAttributedStringMBS.attributedStringWithString("Hello World")
Dim m As NSMutableAttributedStringMBS = a.mutableCopy

r = New NSRangeMBS(0,5)
m.addAttribute(m.NSFontAttributeName, NSFontMBS.boldSystemFontOfSize(13), r)

Declare Sub setAttributedText Lib "UIKit" Selector "setAttributedText:" (NSTextViewRef As ptr, AttributedStringHandle As Integer )

setAttributedText Label1.Handle, m.Handle

which seems to work to get bold font there into the label.

But NSSuperscriptAttributeName isn’t available for iOS as far as I see.

I also make a blog post: Styled Text for Labels in your Xojo iOS app

1 Like

Thanks for this, Christian

1 Like
Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.