pub struct DrawingToolShortcuts { /* private fields */ }Expand description
Keyboard shortcuts for drawing tools
§Examples
use egui_charts::ui::drawing_toolbar::DrawingToolShortcuts;
use egui_charts::drawings::DrawingToolType;
use egui::{KeyboardShortcut, Key, Modifiers};
let mut shortcuts = DrawingToolShortcuts::new();
// Add custom shortcut
shortcuts.add_shortcut(
KeyboardShortcut::new(Modifiers::CTRL, Key::D),
DrawingToolType::TrendLine
);Implementations§
Source§impl DrawingToolShortcuts
impl DrawingToolShortcuts
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a DrawingToolShortcuts with default settings.
Sourcepub fn check(&self, ctx: &Context) -> Option<DrawingToolType>
pub fn check(&self, ctx: &Context) -> Option<DrawingToolType>
Check for keyboard shortcuts and return the tool if one was triggered
§Examples
use egui::{Event, Key, Modifiers, RawInput};
use egui_charts::drawings::DrawingToolType;
use egui_charts::ui::drawing_toolbar::DrawingToolShortcuts;
let shortcuts = DrawingToolShortcuts::new();
let ctx = egui::Context::default();
// A frame in which the user pressed Alt+T.
let mut input = RawInput::default();
input.events.push(Event::Key {
key: Key::T,
physical_key: None,
pressed: true,
repeat: false,
modifiers: Modifiers::ALT,
});
let mut triggered = None;
ctx.run_ui(input, |ui| triggered = shortcuts.check(ui.ctx()))
.drop_without_applying_deltas();
assert_eq!(triggered, Some(DrawingToolType::TrendLine));Sourcepub fn add_shortcut(
&mut self,
shortcut: KeyboardShortcut,
tool: DrawingToolType,
)
pub fn add_shortcut( &mut self, shortcut: KeyboardShortcut, tool: DrawingToolType, )
Add a custom shortcut
§Examples
let mut shortcuts = DrawingToolShortcuts::new();
shortcuts.add_shortcut(
KeyboardShortcut::new(Modifiers::CTRL, Key::T),
DrawingToolType::TrendLine
);Trait Implementations§
Auto Trait Implementations§
impl Freeze for DrawingToolShortcuts
impl RefUnwindSafe for DrawingToolShortcuts
impl Send for DrawingToolShortcuts
impl Sync for DrawingToolShortcuts
impl Unpin for DrawingToolShortcuts
impl UnsafeUnpin for DrawingToolShortcuts
impl UnwindSafe for DrawingToolShortcuts
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more