Explaining selectionStart in Dash Input component

I’ve been trying to use selectionStart inside the dcc.Input() but I’m not sure how to make it work according to the documentation. This is my code so far:

app.layout = html.Div([
    html.Div([
        dcc.Input(
            id='my_txt_input',
            type='text',
            debounce=True,
            #selectionStart=" ",
        ),
    ]),

    html.Div(id='div_output'),

    html.P(['Selection Start:']),
    html.Div(id='div_slct_Start'),

])

@app.callback(
    [Output(component_id='div_output', component_property='children'),
     Output(component_id='div_slct_Start', component_property='children')
    ],
    [Input(component_id='my_txt_input', component_property='value'),
     Input(component_id="my_txt_input", component_property='selectionStart')
    ]
)

def update_input(txt_inserted, slct_start)
    return(txt_inserted, slct_start)

Nothing seems to happen, and I always get a None type. This example demonstrates how selectionStart is read.

Can someone please explain how selectionStart works inside dcc.Input()
Thank you,

Is there any update on this? I have been trying to get cursor position in input field so I could insert text on that position and I came across selectionStart and selectionEnd properties, but they do not seem to work. I also always get a None type when using them with n_submit or n_blur properties of Input for callback

Decided to start a New Topic since this is a 2-parter and since this thread has been dormant for over a year.


Moving to New Topic:

Me too.

Supplying selectionStart (or -End) as a callback Input or State only ever gives me the initial value (provided I had set one explicitly in the layout). My code is essentially identical to adamschroeder’s (above).

Also, I ultimately will need to use this functionality in a Textarea also, but I only see this property associated with Input. That seems like an odd asymmetry. It’s arguably even more useful in a Textarea where people might be expected to do more complex editing etc - you know, as I am literally doing as I type this. :wink: In fact, my goal is to put some Markdown buttons on my Inputs and Textareas not unlike what is on this very widget.

Thanks a bunch!
John