Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable hotkeys #77

Merged
merged 38 commits into from
Nov 25, 2023
Merged

Configurable hotkeys #77

merged 38 commits into from
Nov 25, 2023

Conversation

rewin123
Copy link
Owner

@rewin123 rewin123 commented Nov 24, 2023

Hotkey can be created with one method

app.editor_hotkey(GizmoHotkey::Translate, vec![KeyCode::G]);

where the vector defines default the set of keys required to press and activate the hotkey.
Hotkey use example

fn dummy(input : Res<Input<GizmoHotkey>>) {
   if input.just_pressed(GizmoHotkey::Translate) {
         info!("You pressed translate hotkey");
   }
}

Hotkey struct example

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Reflect)]
pub enum GizmoHotkey {
    Translate,
    Rotate,
    Scale,
}

impl Hotkey for GizmoHotkey {
    fn name(&self) -> String {
        match self {
            GizmoHotkey::Translate => "Translate entity".to_string(),
            GizmoHotkey::Rotate => "Rotate entity".to_string(),
            GizmoHotkey::Scale => "Scale entity".to_string(),
        }
    }
}

UI example
image

With persistance_editor feature hotkeys will be saved in editor_settings.rs

Todo:

  • Multiple hotkey recording in UI for key combinations in one hotkey
  • Clean ui
  • Move all static hotkeys to configurable hotkeys

@rewin123 rewin123 marked this pull request as ready for review November 25, 2023 12:07
@rewin123 rewin123 merged commit 637a501 into main Nov 25, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants