I'm using widget.NewMultiLineEntry()
in my GUI application to create a multi-line text entry widget. I'm looking for a way to automatically or manually scroll to the bottom of the widget whenever new content is added. How can I achieve this behavior? Is it even possible?
logsBox := widget.NewMultiLineEntry()
logsBox.Wrapping = fyne.TextTruncate
logsBox.SetMinRowsVisible(3)
logsBox.SetPlaceHolder("Waiting for logs...")
logsBox.OnChanged = func(newMsg string) {
// ...
}
logsBox.SetText("Row 1\nRow 2\nRow 3\nRow 4")
// TODO: Scroll to the bottom manually somehow?
Looks like we can use CursorRow
property to solve this:
focusedItem := logsWindow.Canvas().Focused()
// If the user is not focused on the text area then scroll to the end
if focusedItem == nil || focusedItem != logsBox {
logsBox.CursorRow = len(logsBox.Text) - 1 // Sets the cursor to the end
}