LibreOffice Basic, about cursor position

Hi all gurus!

I’ve been looking for a solution to this for a while, but to no avail…
So I would be very grateful :blush: if someone could shed some light on, how to move the cursor to the end of the text in a Dialog textbox after setFocus, with code.

Thanks in advance
Pertsa

Please upload an ODF type sample file with the (half-finished) embedded macro code here.

The simplest solution always works best :slightly_smiling_face:

Sub SayHelloWorld

    oDlg.Model.getByName("TextField1").Text = "Hello World"
    oControl = oDlg.getControl("TextField1")
    oView = oControl.getView()
    oView.setFocus()
    
    Dim textLen As Integer
    textLen = Len(oDlg.Model.getByName("TextField1").Text)
    
    ' Create a Selection structure
    Dim oSelection As New com.sun.star.awt.Selection
    oSelection.Min = textLen
    oSelection.Max = textLen
    
    ' Move the cursor to the end of the text
    oView.setSelection(oSelection)
    
    oView = Nothing
    
End Sub