Show invisible characters in MobileTextArea

I’m trying to get a MobileTextArea to show invisible characters using declares, but I’m not able to figure it out.

This is the code I have in the open event of the MobileTextArea, but the simulator crashes as soon as it reaches the showInvisibles line.

Has anyone done this before?

Declare Sub showInvisibles Lib "UIKit" Selector "showsInvisibleCharacters:" (obj As Ptr, value As Boolean)
showInvisibles(Me.Handle, True)

Apple Developer Documentation for showsInvisibleCharacters

the selector should be

1 Like

Unfortunately it still crashes with setShowsInvisibleCharacters.

Maybe, because your selector ist part of NSLayoutManager. So I believe that’s the reason, because you use the handle of the MobileTextArea.

Yeah I was about to say the same thing. I’m guessing the crash is due to an Unrecognized selector for the text field. Mark will need to get/set the layout manager of the text field then invoke that selector onto the layout manager

1 Like

Try this:

Declare Function layoutManager Lib "UIKIt" Selector "layoutManager" (obj As Ptr) As Ptr
Var oLayoutManager As Ptr = layoutManager(Me.Handle)

Declare Sub showInvisibles Lib "UIKit" Selector "setShowsInvisibleCharacters:" (obj As Ptr, value As Boolean)
showInvisibles(oLayoutManager, True)

1 Like

Thank you! That works. It shows all the invisible characters, except the Carriage Return ( ¶ )

There is a show control characters function as well that you’ll need for that I would guess.

I tried that by adding this code to what Martin showed:

Declare Sub showControlchars Lib "UIKit" Selector "setShowsControlCharacters:" (obj As Ptr, value As Boolean)
showControlchars(oLayoutManager, True)

Still no Carriage Return characters at the end of a line.

Are you sure there are carriage return characters present? On iOS I believe it would just be line feed characters, not carriage returns unless you are explicitly adding them

I’ve tried EndOfLine.iOS, EndOfLine.CR, EndOfLine.LF, EndOfLine.CRLF, and replaceAll(EndOfLine.CRLF, Encodings.ASCII.Chr(13))

None of them show a Carriage Return symbol.