Constantin Birkert
02/25/2024, 1:49 PMNick
02/25/2024, 7:35 PMStyledText
and text Decoration
. you can modify the background and foreground using this approach when rendering text.
the existing TextField
only supports single lined, installed text. so you’d need to build a custom component for this. this also makes sense because an editor would need to do a lot more clever things to support very large text data (i.e. only render sub portions of it).
this is an exciting project. would love to see what you build and whether the text control could be general purpose enough to be a new component within Doodle’s controls
library, if you’d be interested in contributing.Constantin Birkert
02/25/2024, 7:41 PMNick
02/25/2024, 7:47 PMConstantin Birkert
02/29/2024, 10:45 AMNick
03/02/2024, 5:21 AMView
that gains focus will receive key inputs if you’ve installed the KeyboardModule
when launching your app.
cursor drawing and text selection would be custom. right now only the TextField with a nativeTextFieldBehavior() handles cursor and selection. but that comes from outside Doodle. this means you’d have to create your own.
cursor drawing would be easy (once you know where you’d like to draw it 😁). take a look at how basic shapes are drawn to see how you could use a simple filled rect or more complex path to render it to the Canvas. you’ll need to decide if the cursor is drawn in the same View
as your text, or if you draw it to a separate one that is overlayed. doing the latter could be faster if your cursor blinks since it would avoid redrawing the text on each blink cycle.
text selection isn’t directly supported yet in Doodle. though i’ve started thinking about how to do this in a way that allows integration with the platform so you’d get things like clipboard and drag-drop support by default. that said, you can still build this yourself. i’d suggest using StyledText with background/foreground decoration to represent the selection.
highlighting only solves the visual part of selection. you’d need to handle things like key input to modify, copy, paste the selection etc. you’d also want to wire drag-drop for the text component so you could use the pointer to move the selected text for example. this part is straightforward though, once you know where your selection is and what text it contains.