Adventures in TextInputCanvas : 1

Since I’m working on some code that needs to implement a custom text editor I thought I’d write up my findings here for anyone else that needs to follow along
Along the way I can guarantee you I will make mistakes and missteps

But thats the point - to write up everything that goes into figuring out this poorly understand and under documented control in the Xojo Tool kit.

Off To the Races

First things first.
While you CAN just drop an instance on a layout and try to deal with things in that instance - dont.
There are a lot of things you will end up needing to deal with and trying to do all of it within a subclass will make life simpler since you can add private and protected consts, properties, methods etc.
And if you want you’ll be able to add event definitions etc for other bits of your application to respond to.
Trying to do that in instances on a layout is just asking for a painful experience.

So, step one is to drag a new instance of TextInputCanvas over into the navigator to make a new subclass of it.
And we can actually quick ly implement perhaps the simplest of all events - Paint.
Since this IS a canvas we get the pleasure (pain?) of implementing EVERYTHING - drawing text drawing rulers drawing ever last darned thing
SO you can add the paint event and just put

g.forecolor = &cFF000000
g.FillRect 0, 0, g.Height, g.width

Drag an instance of our new subclass onto a window and hit run.
Yay ! It should be bright red.
And that is likely the end of the trivial code we’ll have for this thing :slight_smile:

1 Like