Fast RTF for TextArea?

I use the following functions to speed up the RTF handling of the TextArea:

Public Sub BeginFastEditing(Extends TA As TextArea)
  
  #If TargetCocoa Then
    
    Dim docView As Integer = TA.DocumentView
    ' Dim storage As Integer = TA.TextStorage( docView )
    Dim storage As Integer = TextStorage( docView )
    
    Declare Sub beginEditing Lib "AppKit" Selector "beginEditing" ( obj As Integer )
    beginEditing( storage )
    
  #EndIf
End Sub

and

Public Sub EndFastEditing(Extends TA As TextArea)
  
  #If TargetCocoa Then
    
    Dim docView As Integer = TA.DocumentView
    ' Dim storage As Integer = TA.TextStorage( docView )
    Dim storage As Integer = TextStorage( docView )
    
    Declare Sub endEditing Lib "AppKit" Selector "endEditing" ( obj As Integer )
    endEditing( storage )
    
  #Endif
End Sub

Is there any reason why I couldn’t simply add these to a custom class FastTextArea and have it in the open and close events?

Nope, that should work :slight_smile:

I dont think you want to leave those open quite that long

I’d shadow the SETTER for Text and maybe StyledText and wrap all the code in there with these

Basically they for ma “transaction” and if you leave them open for the life of the field you may never see updates

Bummer.

Oooookay … how?

I have a blog post about that :stuck_out_tongue:

https://www.great-white-software.com/blog/2019/06/17/follow-up-on-why-shadowing-should-be-avoided/

  1. subclass text area
  2. define a new computed property - Text
  3. the setter then calls the code to start the edit above, sets the Supers text (as demonstrated in my blog post), the end the edit
  4. same for StyledText maybe or RTF text etc
1 Like

Won’t let me.

I’ve seen your blog post on overcoming that, but I’m not sure I want to go down that rabbit hole …

AH right the “cant name it Text thing”

The other option to to name it something else and then in your subclass remove Text from the inspector behaviour
That just means it wont be seen in the inspector though and programmatically you could still set “Text” and thereby circumvent your work :frowning:

Jup - doesn’t display anything at all as it isn’t updating until the EndFastEditing runs …