Can I intercept Escape press or change lose focus trigger of a text_editor widget(or any other)?

I am trying to do a simple, let’s say, vim like text editor using text_editor widget.

The problem is that it loses focus if I hit escape. I want to change that behavior but I don’t know how to do it.

I have tried bind escape press in subscription to some message, but it doesn’t work, like event is already consumed when I try to catch it.

fn subscription(&self) -> Subscription<Message> {
    keyboard::on_key_press(|key, modifiers| match key.as_ref() {
        keyboard::Key::Named(keyboard::key::Named::Escape) => Some(Message::DoSomethingOtherThenLoseFocus),
        _ => None,
    })
}

The question is can I intersect key press event and drop it in some way?
Or maybe I can change the trigger for lose focus event?

I am sure I am doing something wrong, would be glad for any kind of guidance.

I am on 0.12.1 right now.

You can’t. You will need to catch the Escape key press event and use it to re-focus the text editor, although I would say your best bet is to fork Iced and remove that behavior from it.

I think that creating a new widget that is just a wrapper around the text_editor and define the on_event method of the Widget Trait.
In this method, if the event is a escape key press, ignore, else transfer the event to the underlying text_editor.
Similarly to what we did for the typed_input and the number_input in iced_aw

Thanks, probably would end up using something else and come back when it hits 0.13 or gets better docs, as I understand it should be relatively soon.

Luck of documentation is frustrating for newbeis like me. Just to many blind spots that I can’t figure out or get stuck for a long time.

But the aproach with ELM architecture is very appealing. I think the project has very bright future.

Will definetely check out iced_aw and see how things done there so! Thank you for helping me =)