mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Fix bugs in consume_key and improve Modifiers API
Improvements and fixes following https://github.com/emilk/egui/pull/1212
This commit is contained in:
@@ -64,7 +64,10 @@ impl super::View for TextEdit {
|
||||
anything_selected,
|
||||
egui::Label::new("Press ctrl+T to toggle the case of selected text (cmd+T on Mac)"),
|
||||
);
|
||||
if ui.input().modifiers.command_only() && ui.input().key_pressed(egui::Key::T) {
|
||||
if ui
|
||||
.input_mut()
|
||||
.consume_key(egui::Modifiers::COMMAND, egui::Key::T)
|
||||
{
|
||||
if let Some(text_cursor_range) = output.cursor_range {
|
||||
use egui::TextBuffer as _;
|
||||
let selected_chars = text_cursor_range.as_sorted_char_range();
|
||||
|
||||
@@ -126,10 +126,7 @@ fn shortcuts(ui: &Ui, code: &mut dyn TextBuffer, ccursor_range: &mut CCursorRang
|
||||
(Key::S, "~"), // ~strikethrough~
|
||||
(Key::U, "_"), // _underline_
|
||||
] {
|
||||
if ui
|
||||
.input_mut()
|
||||
.consume_key(egui::Modifiers::new().command(true), key)
|
||||
{
|
||||
if ui.input_mut().consume_key(egui::Modifiers::COMMAND, key) {
|
||||
toggle_surrounding(code, ccursor_range, surrounding);
|
||||
any_change = true;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user