Text editor object in an future update?

I have finished my story developing/writing app, but still am doubting of releasing it because the place where a user actually start writing the story feels too basic. It’s done in a text area field, the only way at this moment in Xojo, which gives not enough options for a user to do things every basic word processor can do (bold, center text etc). Are there plans to add a text editor object somewhere in a future update?

For macOS you can turn the TextArea into a text editor:
Just add this in the Open event of the TextArea.

declare function documentView lib "Cocoa" selector "documentView"(obj_id as Integer) as Integer
declare sub setUsesInspectorBar lib "Cocoa" selector "setUsesInspectorBar:" (obj_id as Integer, value as Boolean)
setUsesInspectorBar(documentView(Integer(me.Handle)), true)

Did you ever investigate the Open Source Formatted Text Control?

there is nothing like that in the roadmap at least …
https://documentation.xojo.com/resources/roadmap.html

I can provide you with my Rich Text control, for free, to try.

2 Likes

This adds a formatting bar to the window which is great, thanks! It doesn’t seem to save any changes I make to the text though.

I looked around, but could not get it to work. Not sure if I checked out this one, though, thanks.

Nice… very nice…

It does add some editing controls below the title-bar.

But it pushes all the controls in the window down. Some buttons I have at the bottom partially disappear. But when I resize the window, all controls move to their correct position.
Is there a way to fix that?

By the way, I subclassed the DesktopTextArea, and added a method

Public Function EditorMode(Assigns Value As Boolean)
    Declare Function documentView Lib "Cocoa" Selector "documentView"(obj_id As Integer) As Integer
    Declare Sub setUsesInspectorBar Lib "Cocoa" Selector "setUsesInspectorBar:" (obj_id As Integer, value As Boolean)
    
    setUsesInspectorBar(documentView(Integer(Me.Handle)), Value)
End Function

I also tested it when Styled Text was not allowed. And it still gave me the Editing options, including changing some text to a Bold font. :thinking:

It is nice to have that toolbar, but it is not really working as expected. Applying a specific style like Bold or Center to a selected text will apply it still to all the text in a text field. I really hope the day will come that Xojo will have a professional text editor.

I would be very happy if you could provide us with a version. I have encountered the same problems as André. My biggest problem with the Cocoa solution is that the toolbar always docks to the window and not to the container in which I need it. I also have the formatting problems like Andre’. I have already invested several days in FTC (porting to API2 etc.) but in the end the result did not justify the effort.

Center the text would apply over one line only, I think.

But I did test setting one word to Bold. And that worked as expected. Just one word, not the entire text.

Yeah, the HTMLviewer works pretty good.
With the help of some JavaScript, I was even able to add clickable Token-Elements.

The Xojo app is then notified when the user clicked on such a token. I didn’t have it work flawlessly. But it did the job, for me.

I don’t know how I would add Token-Elements to a TextArea though.

A while ago I saw some examples to turn a Canvas into a text-editor. But I found it rather complex. Isn’t the Code-Editor in Xojo not based on a canvas? I vaguely remember Paul or Geoff talking about that, in a webinar.
I can imagine, that having a TextArea based on a Canvas, there is a lot more control over the behavior of the control.

Yes, this works also in my app, but after saving the text to a database and then reading it back into the text field will show that style applied to the full ext field.

That’s odd…

Did you read the styled text, when saving it to the database?
Maybe you could check how many styleruns there are, and inspect those styleruns. :thinking: