dioxus_desktop/
mobile_shortcut.rs1#![allow(unused)]
2
3use super::*;
4use std::str::FromStr;
5use tao::event_loop::EventLoopWindowTarget;
6
7use dioxus_html::input_data::keyboard_types::Modifiers;
8
9#[derive(Clone, Debug)]
10pub struct Accelerator;
11
12#[derive(Clone, Copy)]
13pub struct HotKey;
14
15impl HotKey {
16 pub fn new(mods: Option<Modifiers>, key: Code) -> Self {
17 Self
18 }
19
20 pub fn id(&self) -> u32 {
21 0
22 }
23}
24
25impl FromStr for HotKey {
26 type Err = ();
27
28 fn from_str(s: &str) -> Result<Self, Self::Err> {
29 Ok(HotKey)
30 }
31}
32
33pub struct GlobalHotKeyManager();
34
35impl GlobalHotKeyManager {
36 pub fn new() -> Result<Self, HotkeyError> {
37 Ok(Self())
38 }
39
40 pub fn register(&self, accelerator: HotKey) -> Result<HotKey, HotkeyError> {
41 Ok(HotKey)
42 }
43
44 pub fn unregister(&self, id: HotKey) -> Result<(), HotkeyError> {
45 Ok(())
46 }
47
48 pub fn unregister_all(&self, _: &[HotKey]) -> Result<(), HotkeyError> {
49 Ok(())
50 }
51}
52
53use std::{error, fmt};
54
55#[non_exhaustive]
57#[derive(Debug)]
58pub enum HotkeyError {
59 AcceleratorAlreadyRegistered(Accelerator),
60 AcceleratorNotRegistered(Accelerator),
61 HotKeyParseError(String),
62}
63
64impl error::Error for HotkeyError {}
65impl fmt::Display for HotkeyError {
66 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
67 match self {
68 HotkeyError::AcceleratorAlreadyRegistered(e) => {
69 f.pad(&format!("hotkey already registered: {:?}", e))
70 }
71 HotkeyError::AcceleratorNotRegistered(e) => {
72 f.pad(&format!("hotkey not registered: {:?}", e))
73 }
74 HotkeyError::HotKeyParseError(e) => e.fmt(f),
75 }
76 }
77}
78
79pub struct GlobalHotKeyEvent {
80 pub id: u32,
81 pub state: HotKeyState,
82}
83
84#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
86pub enum HotKeyState {
87 Pressed,
89 Released,
91}
92
93pub(crate) type Code = dioxus_html::input_data::keyboard_types::Code;