Create Subclass of TextInputCanvas

Hi everyone,

days ago, i studied @Bob Keeneys TextInputCanvas Sample-Project. It’s good to start with this control. I thought about how to extend these Control to use it as a minimal Word-Processor. I know Bob’s Formated Text Control, but i think it’s cool to have a look, how i’m able to do simple RichText-things with that control.

[h]Multiline Text[/h]
It’s simple along you use a single TextFont and TextSize.

  1. split your Text into an Paragraph-Array by EndOfLine-Seperator
  2. check, if StringWidth of each line > TextInputCanvas.Width. If yes, split again, if no, everythigs fine
  3. draw each Paragraph/line

[h]Formatted Text[/h]

  1. each Paragraph (line) has multiple words, characters.
  2. each character could have his own TextFont, TextSize, TextColor (enough at the moment)
  3. to calculate the current LineWidth we need to add the Width of each Character and check if total width of TextInputCanvas < or > LineWidth, again yes or no…
  4. how to calculate LineHeight? Need to check every Characters TextSize. Biggest TextSize = LineHeight



  • TextFont
  • TextSize
  • TextColor


  • Array of Characters
  • GetWordWidth As Integer
  • GetWordHeight As Integer // highest character


  • Array of Words
  • GetLineWidth As Integer
  • Get LineHeight As Integer // highest word

You see, just some thoughts about so a task.

How would you go on with a concept? How to do the calculations? Any input, additions? Someone interested to work on such a control together?


Hi everyone,

sad no one has some input :wink:

I created a small sample Subclass based on @Bob Keeney 's Sample. It has the following modifications:

I tried to use the cmdPaste in DoCommand to insert Text from Clipboard, but it doesn’t work. Why?

case CmdPaste

Dim c As New Clipboard
If c.TextAvailable Then
InsertText(c.Text, mSelection)
End If

How to go on? My goal is to make it work with multiline Text. But how?

  • you have to recalculate the Baseline für each Line
  • a Line is defined as an string with &uA as his last character
  • how to do auto linebreak, if line.width >= TextInputCanvas.Width
  • how to set/use blinking caret in multilined Text?
  • how to realize formatted Textoutput? Each character has a own fontsize and font? Line.Width = Width of each character (graphics.StringWidth(currentCharacter)). Baseline of currentLine = which character within line has the biggest fontsize?

someone up to work together on it?


Hi Martin,

I will need a multi-line version as well in the near future as I’ll have a project that will require it. I will definitely be working on this, or even subcontracting someone to do it (maybe some dollars for you Bob?). I’m not ready right now, however. But I’ll be sure to post my progress and results in this thread.

Formatted Text Control is a very large project and it’s really showing its age. It was written many years ago before Cocoa, and 64 bit, Linux, and HiDPI were a concern. What I really need to do it rewrite it to modern standards. However, that’s a HUGE undertaking and right now Shorts is our #1 priority. Having a consulting project or two would definitely speed things up though.

Dear Bob,

i can understand you. :wink: Can you tell me, why cmdPaste (as shown in my last Post) doesn’t work?
And are my steps the right ones? Or am i wrong with my thoughs about how to perform multiline and multi styled text?

I’m in the middle of a bunch of work so I haven’t had time to look at your project. Sorry.

Cant open or use that sample project at all

[quote=310835:@Norman Palardy]You do realize you dont need ANY plugin to subclass TextInputCanvas on any platform
TextInputCanvas is built into the IDE
Simply create a class and set its super to “TextInputCanvas”[/quote]

I had no idea.

You have to copy the MBS Plugin into Xojo’s Pluginfolder

yeah I’m wrong I always forget that of course I have ours installed :stuck_out_tongue:

Yeah even then it crashes the IDE
No idea why

[quote=310846:@Norman Palardy]Yeah even then it crashes the IDE
No idea why[/quote]
Really? I use Xojo 2016.4.1
Load it again from Christians MBS-Site

crashes my set up 100% of the time repeatedly
I tried 5 times then gave up

File a feedback report with your crash log.
I kind of want to see if that’ll create a loop of logic and end the world.

I already did

turns out its a duplicate of

Thanks for your time Norman. I don’t know why it doesn’t work. Hope you can try later.

I didn’t feel so much as a tremble.

I know what it is now
opens fine for me now

[quote=310826:@Martin Trippensee]I tried to use the cmdPaste in DoCommand to insert Text from Clipboard, but it doesn’t work. Why?

case CmdPaste

Dim c As New Clipboard
If c.TextAvailable Then
InsertText(c.Text, mSelection)
End If

I made it work by implementing : enablemenuitem ( enable editpaste when there is text in the clipboard)
and the editpaste menuhandler using inserttext method to do the paste.
but yes it seems that the docommand paste command doesnt fire.