• Auto-expanding a MultilineTextEdit

    From Joe Betz@21:1/5 to All on Tue Feb 22 13:51:14 2022
    How do you configure a MultilineTextEdit to increase in height whenever text wraps to a new line or a newline gets added (i.e., by pressing enter)?

    Context: The MultilineTextEdit is inside a ContainerView using ProportionalLayout with arrangement set to 0. I tried enabling `usePreferredExtent`, recalculating the extent with every key typed, and then updating it using `preferredExtent:`, but the edit
    field remains the same size.

    I have a strong feeling that it's an issue with the layouts but I can't figure out a better way to arrange things to get the behavior I want.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Joe Betz@21:1/5 to All on Fri Feb 25 23:13:14 2022
    <sigh> There was an extra ContainerView that was screwing things up, inbetween the input field and the view where the layout was correctly defined. Got rid of that and `preferredExtent:` is now working as expected.

    onKeyTyped: aKeyEvent on: aTextInput
    | newExtent |
    newExtent := aTextInput calculateExtent: (LayoutContext forContainer: self).
    (newExtent y < 250) ifTrue: [ aTextInput preferredExtent: newExtent ]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)