How can I press "Enter" on cell in cell edit mode

Hi All. I’m trying to emulate enter/esc keys in cell edit mode with python. Qwen has offered me the next approach which I try to use in my context. But it doesn’t work, simply nothing matters…
Does anybody know how to do this?

    ctx = XSCRIPTCONTEXT.getComponentContext()
    dispatcher = ctx.getServiceManager().createInstanceWithContext("com.sun.star.frame.DispatchHelper", ctx)
    doc = XSCRIPTCONTEXT.getDocument()
    frame = doc.getCurrentController().getFrame()

    # Dispatch 'Enter' to confirm edit and exit
    dispatcher.executeDispatch(frame, ".uno:Enter", "", 0, ())

I wonder where Qwen got its inspiration. I dont see your/its uno:Enter in the following list:
https://wiki.documentfoundation.org/Development/DispatchCommands

I’ve tried “.uno:Escape” from the list too, but without any result(

… for Writer.

For Calc might be .uno:Cancel

and of course the critical question : WHY ? :thinking:

XY problem - Wikipedia

When user entered in cell edit mode, I need to commit or reject changes depends on data. The best way I think is to emulate Enter/Esc keypress, as it works in the interface

Yes, this works to cancel edit mode, thanks. But I need “Enter” too

your description, again, is about how YOU think to solve »something« but not a description of »something« … this phenomen is called »x-y-problem« as already pointed by @fpy.

how about Validity of Cell Contents ?

See here.


@librebel is definitely not an AI. :slight_smile: