2
0
Эх сурвалжийг харах

Right-click popups will stay till next tap, in line with Android UI

Ivan Savenko 2 жил өмнө
parent
commit
18388b2d72

+ 10 - 0
client/eventsSDL/InputSourceTouch.cpp

@@ -79,6 +79,7 @@ void InputSourceTouch::handleEventFingerMotion(const SDL_TouchFingerEvent & tfin
 			break;
 		}
 		case TouchState::TAP_DOWN_LONG:
+		case TouchState::TAP_DOWN_LONG_AWAIT:
 		{
 			// no-op
 			break;
@@ -118,6 +119,7 @@ void InputSourceTouch::handleEventFingerDown(const SDL_TouchFingerEvent & tfinge
 		}
 		case TouchState::TAP_DOWN_DOUBLE:
 		case TouchState::TAP_DOWN_LONG:
+		case TouchState::TAP_DOWN_LONG_AWAIT:
 		{
 			// no-op
 			break;
@@ -169,6 +171,14 @@ void InputSourceTouch::handleEventFingerUp(const SDL_TouchFingerEvent & tfinger)
 			break;
 		}
 		case TouchState::TAP_DOWN_LONG:
+		{
+			if (SDL_GetNumTouchFingers(tfinger.touchId) == 0)
+			{
+				state = TouchState::TAP_DOWN_LONG_AWAIT;
+			}
+			break;
+		}
+		case TouchState::TAP_DOWN_LONG_AWAIT:
 		{
 			if (SDL_GetNumTouchFingers(tfinger.touchId) == 0)
 			{

+ 7 - 1
client/eventsSDL/InputSourceTouch.h

@@ -51,9 +51,15 @@ enum class TouchState
 	// single finger is down for long period of time
 	// DOWN -> ignored
 	// MOTION -> ignored
-	// UP -> transition to IDLE, generate onRightClickUp() event
+	// UP -> transition to TAP_DOWN_LONG_AWAIT
 	TAP_DOWN_LONG,
 
+	// right-click popup is active, waiting for new tap to hide popup
+	// DOWN -> ignored
+	// MOTION -> ignored
+	// UP -> transition to IDLE, generate onRightClickUp() event
+	TAP_DOWN_LONG_AWAIT,
+
 
 	// Possible transitions:
 	//                               -> DOUBLE