#![allow(unused)] use super::*; use std::str::FromStr; use wry::application::event_loop::EventLoopWindowTarget; use dioxus_html::input_data::keyboard_types::Modifiers; #[derive(Clone, Debug)] pub struct Accelerator; #[derive(Clone, Copy)] pub struct HotKey; impl HotKey { pub fn new(mods: Option, key: Code) -> Self { Self } pub fn id(&self) -> u32 { 0 } } impl FromStr for HotKey { type Err = (); fn from_str(s: &str) -> Result { Ok(HotKey) } } pub struct GlobalHotKeyManager(); impl GlobalHotKeyManager { pub fn new() -> Result { Ok(Self()) } pub fn register(&mut self, accelerator: HotKey) -> Result { Ok(HotKey) } pub fn unregister(&mut self, id: HotKey) -> Result<(), HotkeyError> { Ok(()) } pub fn unregister_all(&mut self, _: &[HotKey]) -> Result<(), HotkeyError> { Ok(()) } } use std::{error, fmt}; /// An error whose cause the `ShortcutManager` to fail. #[non_exhaustive] #[derive(Debug)] pub enum HotkeyError { AcceleratorAlreadyRegistered(Accelerator), AcceleratorNotRegistered(Accelerator), HotKeyParseError(String), } impl error::Error for HotkeyError {} impl fmt::Display for HotkeyError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { match self { HotkeyError::AcceleratorAlreadyRegistered(e) => { f.pad(&format!("hotkey already registered: {:?}", e)) } HotkeyError::AcceleratorNotRegistered(e) => { f.pad(&format!("hotkey not registered: {:?}", e)) } HotkeyError::HotKeyParseError(e) => e.fmt(f), } } } pub struct GlobalHotKeyEvent { pub id: u32, } impl GlobalHotKeyEvent { pub fn receiver() -> crossbeam_channel::Receiver { crossbeam_channel::unbounded().1 } } pub(crate) type Code = dioxus_html::input_data::keyboard_types::Code;