Merge pull request #7987 from RandomShaper/fix-touch-button-2.1
Several fixes for TouchScreenButton (2.1)
This commit is contained in:
commit
ce09a094ab
2 changed files with 16 additions and 8 deletions
|
@ -135,7 +135,7 @@ void TouchScreenButton::_notification(int p_what) {
|
||||||
update();
|
update();
|
||||||
|
|
||||||
if (!get_tree()->is_editor_hint())
|
if (!get_tree()->is_editor_hint())
|
||||||
set_process_input(true);
|
set_process_input(is_visible());
|
||||||
|
|
||||||
if (action.operator String()!="" && InputMap::get_singleton()->has_action(action)) {
|
if (action.operator String()!="" && InputMap::get_singleton()->has_action(action)) {
|
||||||
action_id=InputMap::get_singleton()->get_action_id(action);
|
action_id=InputMap::get_singleton()->get_action_id(action);
|
||||||
|
@ -147,10 +147,21 @@ void TouchScreenButton::_notification(int p_what) {
|
||||||
if (is_pressed())
|
if (is_pressed())
|
||||||
_release(true);
|
_release(true);
|
||||||
} break;
|
} break;
|
||||||
|
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||||
|
if (get_tree()->is_editor_hint())
|
||||||
|
break;
|
||||||
|
if (is_visible()) {
|
||||||
|
set_process_input(true);
|
||||||
|
} else {
|
||||||
|
set_process_input(false);
|
||||||
|
if (is_pressed())
|
||||||
|
_release();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
case NOTIFICATION_PAUSED: {
|
case NOTIFICATION_PAUSED: {
|
||||||
// So the button can be pressed again even though the release gets unhandled because of coming during pause
|
if (is_pressed())
|
||||||
allow_repress=true;
|
_release();
|
||||||
}
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +248,7 @@ void TouchScreenButton::_input(const InputEvent& p_event) {
|
||||||
if (!is_visible())
|
if (!is_visible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const bool can_press=finger_pressed==-1 || allow_repress;
|
const bool can_press=finger_pressed==-1;
|
||||||
if (!can_press)
|
if (!can_press)
|
||||||
return; //already fingering
|
return; //already fingering
|
||||||
|
|
||||||
|
@ -284,7 +295,6 @@ void TouchScreenButton::_input(const InputEvent& p_event) {
|
||||||
void TouchScreenButton::_press(int p_finger_pressed) {
|
void TouchScreenButton::_press(int p_finger_pressed) {
|
||||||
|
|
||||||
finger_pressed=p_finger_pressed;
|
finger_pressed=p_finger_pressed;
|
||||||
allow_repress=false;
|
|
||||||
|
|
||||||
if (action_id!=-1) {
|
if (action_id!=-1) {
|
||||||
|
|
||||||
|
@ -406,7 +416,6 @@ void TouchScreenButton::_bind_methods() {
|
||||||
TouchScreenButton::TouchScreenButton() {
|
TouchScreenButton::TouchScreenButton() {
|
||||||
|
|
||||||
finger_pressed=-1;
|
finger_pressed=-1;
|
||||||
allow_repress=false;
|
|
||||||
action_id=-1;
|
action_id=-1;
|
||||||
passby_press=false;
|
passby_press=false;
|
||||||
visibility=VISIBILITY_ALWAYS;
|
visibility=VISIBILITY_ALWAYS;
|
||||||
|
|
|
@ -56,7 +56,6 @@ private:
|
||||||
StringName action;
|
StringName action;
|
||||||
bool passby_press;
|
bool passby_press;
|
||||||
int finger_pressed;
|
int finger_pressed;
|
||||||
bool allow_repress;
|
|
||||||
int action_id;
|
int action_id;
|
||||||
|
|
||||||
VisibilityMode visibility;
|
VisibilityMode visibility;
|
||||||
|
|
Loading…
Reference in a new issue