mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Merge pull request #108314 from KoBeWi/shift_in_meta
Replace repetitive meta/ctrl condition with a method
This commit is contained in:
commit
e33c423700
11 changed files with 25 additions and 13 deletions
|
|
@ -158,7 +158,7 @@ void InputEventWithModifiers::set_command_or_control_autoremap(bool p_enabled) {
|
|||
}
|
||||
command_or_control_autoremap = p_enabled;
|
||||
if (command_or_control_autoremap) {
|
||||
if (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) {
|
||||
if (OS::prefer_meta_over_ctrl()) {
|
||||
ctrl_pressed = false;
|
||||
meta_pressed = true;
|
||||
} else {
|
||||
|
|
@ -178,7 +178,7 @@ bool InputEventWithModifiers::is_command_or_control_autoremap() const {
|
|||
}
|
||||
|
||||
bool InputEventWithModifiers::is_command_or_control_pressed() const {
|
||||
if (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) {
|
||||
if (OS::prefer_meta_over_ctrl()) {
|
||||
return meta_pressed;
|
||||
} else {
|
||||
return ctrl_pressed;
|
||||
|
|
@ -245,7 +245,7 @@ BitField<KeyModifierMask> InputEventWithModifiers::get_modifiers_mask() const {
|
|||
mask.set_flag(KeyModifierMask::META);
|
||||
}
|
||||
if (is_command_or_control_autoremap()) {
|
||||
if (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) {
|
||||
if (OS::prefer_meta_over_ctrl()) {
|
||||
mask.set_flag(KeyModifierMask::META);
|
||||
} else {
|
||||
mask.set_flag(KeyModifierMask::CTRL);
|
||||
|
|
|
|||
|
|
@ -361,7 +361,7 @@ bool keycode_has_unicode(Key p_keycode) {
|
|||
|
||||
String keycode_get_string(Key p_code) {
|
||||
Vector<String> keycode_string;
|
||||
if ((p_code & KeyModifierMask::CMD_OR_CTRL) != Key::NONE && !(OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios"))) {
|
||||
if ((p_code & KeyModifierMask::CMD_OR_CTRL) != Key::NONE && !OS::prefer_meta_over_ctrl()) {
|
||||
keycode_string.push_back(find_keycode_name(Key::CTRL));
|
||||
}
|
||||
if ((p_code & KeyModifierMask::CTRL) != Key::NONE) {
|
||||
|
|
@ -373,7 +373,7 @@ String keycode_get_string(Key p_code) {
|
|||
if ((p_code & KeyModifierMask::SHIFT) != Key::NONE) {
|
||||
keycode_string.push_back(find_keycode_name(Key::SHIFT));
|
||||
}
|
||||
if ((p_code & KeyModifierMask::CMD_OR_CTRL) != Key::NONE && (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios"))) {
|
||||
if ((p_code & KeyModifierMask::CMD_OR_CTRL) != Key::NONE && OS::prefer_meta_over_ctrl()) {
|
||||
keycode_string.push_back(find_keycode_name(Key::META));
|
||||
}
|
||||
if ((p_code & KeyModifierMask::META) != Key::NONE) {
|
||||
|
|
|
|||
|
|
@ -55,6 +55,16 @@ OS *OS::get_singleton() {
|
|||
return singleton;
|
||||
}
|
||||
|
||||
bool OS::prefer_meta_over_ctrl() {
|
||||
#if defined(MACOS_ENABLED) || defined(APPLE_EMBEDDED_ENABLED)
|
||||
return true;
|
||||
#elif defined(WEB_ENABLED)
|
||||
return singleton->has_feature("web_macos") || singleton->has_feature("web_ios");
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint64_t OS::get_ticks_msec() const {
|
||||
return get_ticks_usec() / 1000ULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,8 @@ public:
|
|||
|
||||
static OS *get_singleton();
|
||||
|
||||
static bool prefer_meta_over_ctrl();
|
||||
|
||||
void set_current_rendering_driver_name(const String &p_driver_name) { _current_rendering_driver_name = p_driver_name; }
|
||||
void set_current_rendering_method(const String &p_name) { _current_rendering_method = p_name; }
|
||||
void set_gles_over_gl(bool p_enabled) { _is_gles_over_gl = p_enabled; }
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ String EditorSpinSlider::get_tooltip(const Point2 &p_pos) const {
|
|||
String value = get_text_value() + suffix;
|
||||
if (!read_only && grabber->is_visible()) {
|
||||
String tooltip = value;
|
||||
Key key = (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) ? Key::META : Key::CTRL;
|
||||
Key key = OS::prefer_meta_over_ctrl() ? Key::META : Key::CTRL;
|
||||
if (!editing_integer) {
|
||||
tooltip += "\n\n" + vformat(TTR("Hold %s to round to integers."), find_keycode_name(key));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1318,7 +1318,7 @@ Polygon2DEditor::Polygon2DEditor() {
|
|||
action_buttons[ACTION_CREATE]->set_tooltip_text(TTR("Create Polygon"));
|
||||
action_buttons[ACTION_CREATE_INTERNAL]->set_tooltip_text(TTR("Create Internal Vertex"));
|
||||
action_buttons[ACTION_REMOVE_INTERNAL]->set_tooltip_text(TTR("Remove Internal Vertex"));
|
||||
Key key = (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) ? Key::META : Key::CTRL;
|
||||
Key key = OS::prefer_meta_over_ctrl() ? Key::META : Key::CTRL;
|
||||
// TRANSLATORS: %s is Control or Command key name.
|
||||
action_buttons[ACTION_EDIT_POINT]->set_tooltip_text(TTR("Move Points") + "\n" + vformat(TTR("%s: Rotate"), find_keycode_name(key)) + "\n" + TTR("Shift: Move All") + "\n" + vformat(TTR("%s + Shift: Scale"), find_keycode_name(key)));
|
||||
action_buttons[ACTION_MOVE]->set_tooltip_text(TTR("Move Polygon"));
|
||||
|
|
|
|||
|
|
@ -2229,7 +2229,7 @@ TileMapLayerEditorTilesPlugin::TileMapLayerEditorTilesPlugin() {
|
|||
picker_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
picker_button->set_toggle_mode(true);
|
||||
picker_button->set_shortcut(ED_GET_SHORTCUT("tiles_editor/picker"));
|
||||
Key key = (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) ? Key::META : Key::CTRL;
|
||||
Key key = OS::prefer_meta_over_ctrl() ? Key::META : Key::CTRL;
|
||||
picker_button->set_tooltip_text(vformat(TTR("Alternatively hold %s with other tools to pick tile."), find_keycode_name(key)));
|
||||
picker_button->connect(SceneStringName(pressed), callable_mp(CanvasItemEditor::get_singleton(), &CanvasItemEditor::update_viewport));
|
||||
picker_button->set_accessibility_name(TTRC("Pick"));
|
||||
|
|
|
|||
|
|
@ -3152,7 +3152,7 @@ void Node3DEditorViewport::_notification(int p_what) {
|
|||
_update_centered_labels();
|
||||
message_time = MIN(message_time, 0.001); // Make it disappear.
|
||||
|
||||
Key key = (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) ? Key::META : Key::CTRL;
|
||||
Key key = OS::prefer_meta_over_ctrl() ? Key::META : Key::CTRL;
|
||||
preview_material_label_desc->set_text(vformat(TTR("Drag and drop to override the material of any geometry node.\nHold %s when dropping to override a specific surface."), find_keycode_name(key)));
|
||||
|
||||
const int item_count = display_submenu->get_item_count();
|
||||
|
|
|
|||
|
|
@ -1997,7 +1997,7 @@ void ED_SHORTCUT_OVERRIDE_ARRAY(const String &p_path, const String &p_feature, c
|
|||
for (int i = 0; i < p_keycodes.size(); i++) {
|
||||
Key keycode = (Key)p_keycodes[i];
|
||||
|
||||
if (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) {
|
||||
if (OS::prefer_meta_over_ctrl()) {
|
||||
// Use Cmd+Backspace as a general replacement for Delete shortcuts on macOS
|
||||
if (keycode == Key::KEY_DELETE) {
|
||||
keycode = KeyModifierMask::META | Key::BACKSPACE;
|
||||
|
|
@ -2031,7 +2031,7 @@ Ref<Shortcut> ED_SHORTCUT_ARRAY(const String &p_path, const String &p_name, cons
|
|||
for (int i = 0; i < p_keycodes.size(); i++) {
|
||||
Key keycode = (Key)p_keycodes[i];
|
||||
|
||||
if (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) {
|
||||
if (OS::prefer_meta_over_ctrl()) {
|
||||
// Use Cmd+Backspace as a general replacement for Delete shortcuts on macOS
|
||||
if (keycode == Key::KEY_DELETE) {
|
||||
keycode = KeyModifierMask::META | Key::BACKSPACE;
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ String EventListenerLineEdit::get_event_text(const Ref<InputEvent> &p_event, boo
|
|||
String mods_text = key->InputEventWithModifiers::as_text();
|
||||
mods_text = mods_text.is_empty() ? mods_text : mods_text + "+";
|
||||
if (key->is_command_or_control_autoremap()) {
|
||||
if (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) {
|
||||
if (OS::prefer_meta_over_ctrl()) {
|
||||
mods_text = mods_text.replace("Command", "Command/Ctrl");
|
||||
} else {
|
||||
mods_text = mods_text.replace("Ctrl", "Command/Ctrl");
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@ void CodeEdit::gui_input(const Ref<InputEvent> &p_gui_input) {
|
|||
}
|
||||
|
||||
/* Ctrl + Hover symbols */
|
||||
bool mac_keys = OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios");
|
||||
bool mac_keys = OS::prefer_meta_over_ctrl();
|
||||
if ((mac_keys && k->get_keycode() == Key::META) || (!mac_keys && k->get_keycode() == Key::CTRL)) {
|
||||
if (symbol_lookup_on_click_enabled) {
|
||||
if (k->is_pressed() && !is_dragging_cursor()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue