Textarea editing

Forgive me if this topic has been addressed; haven’t found any mention of it though. I have a DesktopListbox cell assigned as TextArea when clicked on. I have not been able to find a way to have it process tabs and returns as usual in text processing; it dumps me out of the cell. I see where that is stated in documentation but no mention of how to capture these keys and integrate them into the text. Does anybody have a solution to this? Thanks!

If you want to handle your own keypresses, you need to do so in the CellKeyDown event, and return True from it to prevent the framework from doing its own thing.

1 Like

Thanks Julia. I’ve tried this with no success but will revisit to see what I may have missed.

What are you trying to do - embed tabs and linefeeds in the cell, or move focus to another cell à la Excel? If the latter, I have working code I can post.

there is a propertie AllowTab in ActiveTextControl (i never used it myself)
AllowTabStop is better disabled in the DesktopListbox.

Basically the chr 9 and 13 arrived in CellKeyDown but not modify the text how it should.

i understood in this way that you will use tab and return in the cell input.

Yes, trying to embed the tabs and linefeeds. Just want the basic text entry functionality.

Hi MarkusR, I’ve been playing with this but can’t find the way to access the cell’s DesktopTextArea to AllowTabs. First CellTypeAt… , then EditCellAt… but to then actually talk to the underlying cell DesktopTextArea…haven’t found that yet. Thanks!

ActiveTextControl returns a TextEdit object, which you need to cast to a TextField before you can access TextField properties.

In the CellKeyDown event handler (API1 code, add “Desktop” as required for API2):

  Dim t As TextArea = TextArea(Me.ActiveTextControl)
  t.AllowTabs = True
  t.Text = t.Text+key // This only _appends_ text; to insert text you'll need to find selection start etc.
  Return True

So far I’m unable to get the listbox to display multiple lines in a cell after editing, but the contents do contain the line feeds and the lines are visible while editing.

1 Like

Super Julia! I set VerticalScrollPosition so when you “Return” below the bottom of the TextArea it scrolls down with you, otherwise “Return” still works but you don’t see your text unless you physically scroll, like with the trackpad…maybe different on other systems.
Thanks!

Var t As DesktopTextArea = DesktopTextArea(Me.ActiveTextControl)
t.AllowTabs = True
t.MultiLine = True
t.Text = t.Text+key // This only _appends_ text; to insert text you'll need to find selection start etc.
t.VerticalScrollPosition = 1000 //arbitrary, don't expect to use 1000 lines in a little note field.
Return True
1 Like