diff --git a/core/input_map.cpp b/core/input_map.cpp index a9ea1d9545f..bd03d61196f 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -282,6 +282,16 @@ void InputMap::load_default() { key->set_scancode(KEY_PAGEDOWN); action_add_event("ui_page_down", key); + add_action("ui_home"); + key.instance(); + key->set_scancode(KEY_HOME); + action_add_event("ui_home", key); + + add_action("ui_end"); + key.instance(); + key->set_scancode(KEY_END); + action_add_event("ui_end", key); + //set("display/window/handheld/orientation", "landscape"); } diff --git a/core/project_settings.cpp b/core/project_settings.cpp index 427fa77e626..22cc592697c 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -1027,6 +1027,20 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("input/ui_page_down", va); input_presets.push_back("input/ui_page_down"); + va = Array(); + key.instance(); + key->set_scancode(KEY_HOME); + va.push_back(key); + GLOBAL_DEF("input/ui_home", va); + input_presets.push_back("input/ui_home"); + + va = Array(); + key.instance(); + key->set_scancode(KEY_END); + va.push_back(key); + GLOBAL_DEF("input/ui_end", va); + input_presets.push_back("input/ui_end"); + //GLOBAL_DEF("display/window/handheld/orientation", "landscape"); custom_prop_info["display/window/handheld/orientation"] = PropertyInfo(Variant::STRING, "display/window/handheld/orientation", PROPERTY_HINT_ENUM, "landscape,portrait,reverse_landscape,reverse_portrait,sensor_landscape,sensor_portrait,sensor"); diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 94e149c8a71..e1cabd3f889 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -199,8 +199,6 @@ void ScrollBar::_gui_input(Ref p_event) { } } - Ref k = p_event; - if (p_event->is_pressed()) { if (p_event->is_action("ui_left")) { @@ -228,20 +226,13 @@ void ScrollBar::_gui_input(Ref p_event) { return; set_value(get_value() + (custom_step >= 0 ? custom_step : get_step())); - } else if (k.is_valid()) { + } else if (p_event->is_action("ui_home")) { - switch (k->get_scancode()) { - case KEY_HOME: { + set_value(get_min()); - set_value(get_min()); + } else if (p_event->is_action("ui_end")) { - } break; - case KEY_END: { - - set_value(get_max()); - - } break; - } + set_value(get_max()); } } } diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index a7a1b499c3c..46215c9277b 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -118,28 +118,14 @@ void Slider::_gui_input(Ref p_event) { return; set_value(get_value() - (custom_step >= 0 ? custom_step : get_step())); accept_event(); + } else if (p_event->is_action("ui_home") && p_event->is_pressed()) { - } else { + set_value(get_min()); + accept_event(); + } else if (p_event->is_action("ui_end") && p_event->is_pressed()) { - Ref k = p_event; - - if (!k.is_valid() || !k->is_pressed()) - return; - - switch (k->get_scancode()) { - - case KEY_HOME: { - - set_value(get_min()); - accept_event(); - } break; - case KEY_END: { - - set_value(get_max()); - accept_event(); - - } break; - } + set_value(get_max()); + accept_event(); } } }