mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 14:49:06 -04:00
Fix TextEdit demo consuming cmd+Y while not being focused (#7846)
The demo should check whether its `TextEdit` is focused before consuming <kbd>cmd+Y</kbd>, in case there are other demos that do the same and come after it. (I found this while experimenting with my own PoC binding and replicating this demo.) | | | |-|-| | before |  | | after |  | * Closes N/A * [x] I have followed the instructions in the PR template
This commit is contained in:
@@ -66,7 +66,8 @@ impl crate::View for TextEditDemo {
|
||||
egui::Label::new("Press ctrl+Y to toggle the case of selected text (cmd+Y on Mac)"),
|
||||
);
|
||||
|
||||
if ui.input_mut(|i| i.consume_key(egui::Modifiers::COMMAND, egui::Key::Y))
|
||||
if output.response.has_focus()
|
||||
&& ui.input_mut(|i| i.consume_key(egui::Modifiers::COMMAND, egui::Key::Y))
|
||||
&& let Some(text_cursor_range) = output.cursor_range
|
||||
{
|
||||
use egui::TextBuffer as _;
|
||||
|
||||
Reference in New Issue
Block a user