Merge pull request #11933 from cxong/master
Use "Command" instead of "Meta" for macOS (#1619)
This commit is contained in:
commit
30dadb1228
6 changed files with 46 additions and 18 deletions
|
@ -278,16 +278,16 @@ String InputEventKey::as_text() const {
|
||||||
return kc;
|
return kc;
|
||||||
|
|
||||||
if (get_metakey()) {
|
if (get_metakey()) {
|
||||||
kc = "Meta+" + kc;
|
kc = find_keycode_name(KEY_META) + ("+" + kc);
|
||||||
}
|
}
|
||||||
if (get_alt()) {
|
if (get_alt()) {
|
||||||
kc = "Alt+" + kc;
|
kc = find_keycode_name(KEY_ALT) + ("+" + kc);
|
||||||
}
|
}
|
||||||
if (get_shift()) {
|
if (get_shift()) {
|
||||||
kc = "Shift+" + kc;
|
kc = find_keycode_name(KEY_SHIFT) + ("+" + kc);
|
||||||
}
|
}
|
||||||
if (get_control()) {
|
if (get_control()) {
|
||||||
kc = "Ctrl+" + kc;
|
kc = find_keycode_name(KEY_CONTROL) + ("+" + kc);
|
||||||
}
|
}
|
||||||
return kc;
|
return kc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,11 @@ static const _KeyCodeText _keycodes[] = {
|
||||||
{KEY_PAGEDOWN ,"PageDown"},
|
{KEY_PAGEDOWN ,"PageDown"},
|
||||||
{KEY_SHIFT ,"Shift"},
|
{KEY_SHIFT ,"Shift"},
|
||||||
{KEY_CONTROL ,"Control"},
|
{KEY_CONTROL ,"Control"},
|
||||||
|
#ifdef OSX_ENABLED
|
||||||
|
{KEY_META ,"Command"},
|
||||||
|
#else
|
||||||
{KEY_META ,"Meta"},
|
{KEY_META ,"Meta"},
|
||||||
|
#endif
|
||||||
{KEY_ALT ,"Alt"},
|
{KEY_ALT ,"Alt"},
|
||||||
{KEY_CAPSLOCK ,"CapsLock"},
|
{KEY_CAPSLOCK ,"CapsLock"},
|
||||||
{KEY_NUMLOCK ,"NumLock"},
|
{KEY_NUMLOCK ,"NumLock"},
|
||||||
|
@ -390,14 +394,22 @@ bool keycode_has_unicode(uint32_t p_keycode) {
|
||||||
String keycode_get_string(uint32_t p_code) {
|
String keycode_get_string(uint32_t p_code) {
|
||||||
|
|
||||||
String codestr;
|
String codestr;
|
||||||
if (p_code & KEY_MASK_SHIFT)
|
if (p_code & KEY_MASK_SHIFT) {
|
||||||
codestr += "Shift+";
|
codestr += find_keycode_name(KEY_SHIFT);
|
||||||
if (p_code & KEY_MASK_ALT)
|
codestr += "+";
|
||||||
codestr += "Alt+";
|
}
|
||||||
if (p_code & KEY_MASK_CTRL)
|
if (p_code & KEY_MASK_ALT) {
|
||||||
codestr += "Ctrl+";
|
codestr += find_keycode_name(KEY_ALT);
|
||||||
if (p_code & KEY_MASK_META)
|
codestr += "+";
|
||||||
codestr += "Meta+";
|
}
|
||||||
|
if (p_code & KEY_MASK_CTRL) {
|
||||||
|
codestr += find_keycode_name(KEY_CONTROL);
|
||||||
|
codestr += "+";
|
||||||
|
}
|
||||||
|
if (p_code & KEY_MASK_META) {
|
||||||
|
codestr += find_keycode_name(KEY_META);
|
||||||
|
codestr += "+";
|
||||||
|
}
|
||||||
|
|
||||||
p_code &= KEY_CODE_MASK;
|
p_code &= KEY_CODE_MASK;
|
||||||
|
|
||||||
|
@ -433,6 +445,21 @@ int find_keycode(const String &p_code) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *find_keycode_name(int p_keycode) {
|
||||||
|
|
||||||
|
const _KeyCodeText *kct = &_keycodes[0];
|
||||||
|
|
||||||
|
while (kct->text) {
|
||||||
|
|
||||||
|
if (kct->code == p_keycode) {
|
||||||
|
return kct->text;
|
||||||
|
}
|
||||||
|
kct++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
struct _KeyCodeReplace {
|
struct _KeyCodeReplace {
|
||||||
int from;
|
int from;
|
||||||
int to;
|
int to;
|
||||||
|
|
|
@ -326,6 +326,7 @@ enum KeyModifierMask {
|
||||||
String keycode_get_string(uint32_t p_code);
|
String keycode_get_string(uint32_t p_code);
|
||||||
bool keycode_has_unicode(uint32_t p_keycode);
|
bool keycode_has_unicode(uint32_t p_keycode);
|
||||||
int find_keycode(const String &p_code);
|
int find_keycode(const String &p_code);
|
||||||
|
const char *find_keycode_name(int p_keycode);
|
||||||
int keycode_get_count();
|
int keycode_get_count();
|
||||||
int keycode_get_value_by_index(int p_index);
|
int keycode_get_value_by_index(int p_index);
|
||||||
const char *keycode_get_name_by_index(int p_index);
|
const char *keycode_get_name_by_index(int p_index);
|
||||||
|
|
|
@ -360,7 +360,7 @@ void ProjectSettingsEditor::_wait_for_key(const Ref<InputEvent> &p_event) {
|
||||||
last_wait_for_key = p_event;
|
last_wait_for_key = p_event;
|
||||||
String str = keycode_get_string(k->get_scancode()).capitalize();
|
String str = keycode_get_string(k->get_scancode()).capitalize();
|
||||||
if (k->get_metakey())
|
if (k->get_metakey())
|
||||||
str = TTR("Meta+") + str;
|
str = vformat("%s+", find_keycode_name(KEY_META)) + str;
|
||||||
if (k->get_shift())
|
if (k->get_shift())
|
||||||
str = TTR("Shift+") + str;
|
str = TTR("Shift+") + str;
|
||||||
if (k->get_alt())
|
if (k->get_alt())
|
||||||
|
@ -642,7 +642,7 @@ void ProjectSettingsEditor::_update_actions() {
|
||||||
|
|
||||||
String str = keycode_get_string(k->get_scancode()).capitalize();
|
String str = keycode_get_string(k->get_scancode()).capitalize();
|
||||||
if (k->get_metakey())
|
if (k->get_metakey())
|
||||||
str = TTR("Meta+") + str;
|
str = vformat("%s+", find_keycode_name(KEY_META)) + str;
|
||||||
if (k->get_shift())
|
if (k->get_shift())
|
||||||
str = TTR("Shift+") + str;
|
str = TTR("Shift+") + str;
|
||||||
if (k->get_alt())
|
if (k->get_alt())
|
||||||
|
|
|
@ -291,7 +291,7 @@ void EditorSettingsDialog::_wait_for_key(const Ref<InputEvent> &p_event) {
|
||||||
last_wait_for_key = k;
|
last_wait_for_key = k;
|
||||||
String str = keycode_get_string(k->get_scancode()).capitalize();
|
String str = keycode_get_string(k->get_scancode()).capitalize();
|
||||||
if (k->get_metakey())
|
if (k->get_metakey())
|
||||||
str = TTR("Meta+") + str;
|
str = vformat("%s+", find_keycode_name(KEY_META)) + str;
|
||||||
if (k->get_shift())
|
if (k->get_shift())
|
||||||
str = TTR("Shift+") + str;
|
str = TTR("Shift+") + str;
|
||||||
if (k->get_alt())
|
if (k->get_alt())
|
||||||
|
|
|
@ -1389,7 +1389,7 @@ bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
|
||||||
if (String(d["type"]) == "obj_property") {
|
if (String(d["type"]) == "obj_property") {
|
||||||
|
|
||||||
#ifdef OSX_ENABLED
|
#ifdef OSX_ENABLED
|
||||||
const_cast<VisualScriptEditor *>(this)->_show_hint(TTR("Hold Meta to drop a Getter. Hold Shift to drop a generic signature."));
|
const_cast<VisualScriptEditor *>(this)->_show_hint(vformat(TTR("Hold %s to drop a Getter. Hold Shift to drop a generic signature."), find_keycode_name(KEY_META)));
|
||||||
#else
|
#else
|
||||||
const_cast<VisualScriptEditor *>(this)->_show_hint(TTR("Hold Ctrl to drop a Getter. Hold Shift to drop a generic signature."));
|
const_cast<VisualScriptEditor *>(this)->_show_hint(TTR("Hold Ctrl to drop a Getter. Hold Shift to drop a generic signature."));
|
||||||
#endif
|
#endif
|
||||||
|
@ -1398,7 +1398,7 @@ bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
|
||||||
if (String(d["type"]) == "nodes") {
|
if (String(d["type"]) == "nodes") {
|
||||||
|
|
||||||
#ifdef OSX_ENABLED
|
#ifdef OSX_ENABLED
|
||||||
const_cast<VisualScriptEditor *>(this)->_show_hint(TTR("Hold Meta to drop a simple reference to the node."));
|
const_cast<VisualScriptEditor *>(this)->_show_hint(vformat(TTR("Hold %s to drop a simple reference to the node."), find_keycode_name(KEY_META)));
|
||||||
#else
|
#else
|
||||||
const_cast<VisualScriptEditor *>(this)->_show_hint(TTR("Hold Ctrl to drop a simple reference to the node."));
|
const_cast<VisualScriptEditor *>(this)->_show_hint(TTR("Hold Ctrl to drop a simple reference to the node."));
|
||||||
#endif
|
#endif
|
||||||
|
@ -1407,7 +1407,7 @@ bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
|
||||||
if (String(d["type"]) == "visual_script_variable_drag") {
|
if (String(d["type"]) == "visual_script_variable_drag") {
|
||||||
|
|
||||||
#ifdef OSX_ENABLED
|
#ifdef OSX_ENABLED
|
||||||
const_cast<VisualScriptEditor *>(this)->_show_hint(TTR("Hold Meta to drop a Variable Setter."));
|
const_cast<VisualScriptEditor *>(this)->_show_hint(vformat(TTR("Hold %s to drop a Variable Setter."), find_keycode_name(KEY_META)));
|
||||||
#else
|
#else
|
||||||
const_cast<VisualScriptEditor *>(this)->_show_hint(TTR("Hold Ctrl to drop a Variable Setter."));
|
const_cast<VisualScriptEditor *>(this)->_show_hint(TTR("Hold Ctrl to drop a Variable Setter."));
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue