Skip to content

Block input from textedit when shortcut or key is consumed #4722

Closed Answered by Kuuuube
Kuuuube asked this question in Q&A
Discussion options

You must be logged in to vote

nvm, managed to get this working. Overwriting the text input events is what is required here.

If anyone else finds this:

Destroying all events when the shortcut is triggered:

if shortcut {
    i.events = vec![];
}
egui::CentralPanel::default().show(ctx, |ui| {
    ui.input_mut(|i| {
        if i.consume_shortcut(&egui::KeyboardShortcut { modifiers: Modifiers::NONE, logical_key: egui::Key::Num1 }) {
            i.events = vec![];
        }
    });

    egui::ScrollArea::vertical().show(ui, |ui| {
        ui.add_sized(
            ui.available_size(),
            egui::TextEdit::multiline(&mut self.text).lock_focus(true),
        );
    });
});

And i.events can be filtered for specifically …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Kuuuube
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant