Prevent shortcuts from being typed into document
This commit is contained in:
parent
5ce34b93c4
commit
27523ef3ea
1 changed files with 14 additions and 6 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
iced::{
|
iced::{
|
||||||
event::{Event, Status},
|
event::{Event, Status},
|
||||||
keyboard::{Event as KeyEvent, KeyCode},
|
keyboard::{Event as KeyEvent, KeyCode, Modifiers},
|
||||||
mouse::{self, Button, Event as MouseEvent, ScrollDelta},
|
mouse::{self, Button, Event as MouseEvent, ScrollDelta},
|
||||||
Color, Element, Length, Padding, Rectangle, Size,
|
Color, Element, Length, Padding, Rectangle, Size,
|
||||||
},
|
},
|
||||||
|
|
@ -407,14 +407,20 @@ where
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
},
|
},
|
||||||
|
Event::Keyboard(KeyEvent::ModifiersChanged(modifiers)) => {
|
||||||
|
state.modifiers = modifiers;
|
||||||
|
}
|
||||||
Event::Keyboard(KeyEvent::CharacterReceived(character)) => {
|
Event::Keyboard(KeyEvent::CharacterReceived(character)) => {
|
||||||
match character {
|
// Only parse keys when Super, Ctrl, and Alt are not pressed
|
||||||
'\n' | '\r' => {}
|
if !state.modifiers.logo() && !state.modifiers.control() && !state.modifiers.alt() {
|
||||||
_ => {
|
match character {
|
||||||
editor.action(Action::Insert(character));
|
'\n' | '\r' => {}
|
||||||
|
_ => {
|
||||||
|
editor.action(Action::Insert(character));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
status = Status::Captured;
|
||||||
}
|
}
|
||||||
status = Status::Captured;
|
|
||||||
}
|
}
|
||||||
Event::Mouse(MouseEvent::ButtonPressed(Button::Left)) => {
|
Event::Mouse(MouseEvent::ButtonPressed(Button::Left)) => {
|
||||||
if let Some(p) = cursor_position.position_in(layout.bounds()) {
|
if let Some(p) = cursor_position.position_in(layout.bounds()) {
|
||||||
|
|
@ -472,6 +478,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct State {
|
pub struct State {
|
||||||
|
modifiers: Modifiers,
|
||||||
is_dragging: bool,
|
is_dragging: bool,
|
||||||
scale_factor: Cell<f64>,
|
scale_factor: Cell<f64>,
|
||||||
handle: Mutex<image::Handle>,
|
handle: Mutex<image::Handle>,
|
||||||
|
|
@ -481,6 +488,7 @@ impl State {
|
||||||
/// Creates a new [`State`].
|
/// Creates a new [`State`].
|
||||||
pub fn new() -> State {
|
pub fn new() -> State {
|
||||||
State {
|
State {
|
||||||
|
modifiers: Modifiers::empty(),
|
||||||
is_dragging: false,
|
is_dragging: false,
|
||||||
scale_factor: Cell::new(1.0),
|
scale_factor: Cell::new(1.0),
|
||||||
//TODO: make option!
|
//TODO: make option!
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue