Add two new default actions ui_end, ui_home

Used by Slider and Scrollbar
This commit is contained in:
Fabio Alessandrelli 2018-02-23 12:17:15 +01:00
parent ff122a7e1f
commit 920d2bfdfa
4 changed files with 34 additions and 33 deletions

View file

@ -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");
}

View file

@ -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");

View file

@ -199,8 +199,6 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
}
}
Ref<InputEventKey> k = p_event;
if (p_event->is_pressed()) {
if (p_event->is_action("ui_left")) {
@ -228,20 +226,13 @@ void ScrollBar::_gui_input(Ref<InputEvent> 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());
}
}
}

View file

@ -118,28 +118,14 @@ void Slider::_gui_input(Ref<InputEvent> 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<InputEventKey> 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();
}
}
}