Rework FileDialog shortcuts
This commit is contained in:
@ -403,9 +403,12 @@ static const _BuiltinActionDisplayName _builtin_action_display_names[] = {
|
||||
{ "ui_graph_delete", TTRC("Delete Nodes") },
|
||||
{ "ui_graph_follow_left", TTRC("Follow Input Port Connection") },
|
||||
{ "ui_graph_follow_right", TTRC("Follow Output Port Connection") },
|
||||
{ "ui_filedialog_delete", TTRC("Delete") },
|
||||
{ "ui_filedialog_up_one_level", TTRC("Go Up One Level") },
|
||||
{ "ui_filedialog_refresh", TTRC("Refresh") },
|
||||
{ "ui_filedialog_show_hidden", TTRC("Show Hidden") },
|
||||
{ "ui_filedialog_find", TTRC("Find") },
|
||||
{ "ui_filedialog_focus_path", TTRC("Focus Path") },
|
||||
{ "ui_swap_input_direction ", TTRC("Swap Input Direction") },
|
||||
{ "ui_unicode_start", TTRC("Start Unicode Character Input") },
|
||||
{ "ui_colorpicker_delete_preset", TTRC("ColorPicker: Delete Preset") },
|
||||
@ -804,6 +807,10 @@ const HashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins() {
|
||||
default_builtin_cache.insert("ui_graph_follow_right.macos", inputs);
|
||||
|
||||
// ///// UI File Dialog Shortcuts /////
|
||||
inputs = List<Ref<InputEvent>>();
|
||||
inputs.push_back(InputEventKey::create_reference(Key::KEY_DELETE));
|
||||
default_builtin_cache.insert("ui_filedialog_delete", inputs);
|
||||
|
||||
inputs = List<Ref<InputEvent>>();
|
||||
inputs.push_back(InputEventKey::create_reference(Key::BACKSPACE));
|
||||
default_builtin_cache.insert("ui_filedialog_up_one_level", inputs);
|
||||
@ -816,6 +823,22 @@ const HashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins() {
|
||||
inputs.push_back(InputEventKey::create_reference(Key::H));
|
||||
default_builtin_cache.insert("ui_filedialog_show_hidden", inputs);
|
||||
|
||||
inputs = List<Ref<InputEvent>>();
|
||||
inputs.push_back(InputEventKey::create_reference(Key::F | KeyModifierMask::CMD_OR_CTRL));
|
||||
default_builtin_cache.insert("ui_filedialog_find", inputs);
|
||||
|
||||
inputs = List<Ref<InputEvent>>();
|
||||
// Ctrl + L (matches most Windows/Linux file managers' "focus on path bar" shortcut,
|
||||
// plus macOS Safari's "focus on address bar" shortcut).
|
||||
inputs.push_back(InputEventKey::create_reference(Key::L | KeyModifierMask::CMD_OR_CTRL));
|
||||
default_builtin_cache.insert("ui_filedialog_focus_path", inputs);
|
||||
|
||||
inputs = List<Ref<InputEvent>>();
|
||||
// Cmd + Shift + G (matches Finder's "Go To" shortcut).
|
||||
inputs.push_back(InputEventKey::create_reference(Key::G | KeyModifierMask::CMD_OR_CTRL));
|
||||
inputs.push_back(InputEventKey::create_reference(Key::L | KeyModifierMask::CMD_OR_CTRL));
|
||||
default_builtin_cache.insert("ui_filedialog_focus_path.macos", inputs);
|
||||
|
||||
inputs = List<Ref<InputEvent>>();
|
||||
inputs.push_back(InputEventKey::create_reference(Key::QUOTELEFT | KeyModifierMask::CMD_OR_CTRL));
|
||||
default_builtin_cache.insert("ui_swap_input_direction", inputs);
|
||||
|
||||
@ -85,6 +85,17 @@ String Shortcut::get_as_text() const {
|
||||
return "None";
|
||||
}
|
||||
|
||||
Ref<Shortcut> Shortcut::make_from_action(const StringName &p_action) {
|
||||
Ref<InputEventAction> event;
|
||||
event.instantiate();
|
||||
event->set_action(p_action);
|
||||
|
||||
Ref<Shortcut> shortcut;
|
||||
shortcut.instantiate();
|
||||
shortcut->set_events({ event });
|
||||
return shortcut;
|
||||
}
|
||||
|
||||
bool Shortcut::has_valid_event() const {
|
||||
// Tests if there is ANY input event which is valid.
|
||||
for (int i = 0; i < events.size(); i++) {
|
||||
|
||||
@ -52,5 +52,7 @@ public:
|
||||
|
||||
String get_as_text() const;
|
||||
|
||||
static Ref<Shortcut> make_from_action(const StringName &p_action);
|
||||
|
||||
static bool is_event_array_equal(const Array &p_event_array1, const Array &p_event_array2);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user