Merge pull request #1579 from ShaharMS/develop

Implement `clickCount` on HTML5 and Native.
This commit is contained in:
player-03
2022-10-10 13:32:34 -04:00
committed by GitHub
7 changed files with 30 additions and 4 deletions

View File

@@ -30,6 +30,7 @@ namespace lime {
int windowID;
double x;
double y;
int clickCount;
static ValuePointer* callback;
static ValuePointer* eventObject;

View File

@@ -4000,7 +4000,7 @@ namespace lime {
#define _TGAMEPAD_EVENT _OBJ (_I32 _I32 _I32 _I32 _F64)
#define _TJOYSTICK_EVENT _OBJ (_I32 _I32 _I32 _I32 _F64 _F64)
#define _TKEY_EVENT _OBJ (_F64 _I32 _I32 _I32)
#define _TMOUSE_EVENT _OBJ (_I32 _F64 _F64 _I32 _I32 _F64 _F64)
#define _TMOUSE_EVENT _OBJ (_I32 _F64 _F64 _I32 _I32 _F64 _F64 _I32)
#define _TRECTANGLE _OBJ (_F64 _F64 _F64 _F64)
#define _TRENDER_EVENT _OBJ (_I32)
#define _TSENSOR_EVENT _OBJ (_I32 _F64 _F64 _F64 _I32)

View File

@@ -622,6 +622,7 @@ namespace lime {
mouseEvent.button = event->button.button - 1;
mouseEvent.x = event->button.x;
mouseEvent.y = event->button.y;
mouseEvent.clickCount = event->button.clicks;
break;
case SDL_MOUSEBUTTONUP:
@@ -632,6 +633,7 @@ namespace lime {
mouseEvent.button = event->button.button - 1;
mouseEvent.x = event->button.x;
mouseEvent.y = event->button.y;
mouseEvent.clickCount = event->button.clicks;
break;
case SDL_MOUSEWHEEL:

View File

@@ -15,6 +15,7 @@ namespace lime {
static int id_windowID;
static int id_x;
static int id_y;
static int id_clickCount;
static bool init = false;
@@ -27,6 +28,7 @@ namespace lime {
y = 0.0;
movementX = 0.0;
movementY = 0.0;
clickCount = 0;
}
@@ -46,6 +48,7 @@ namespace lime {
id_windowID = val_id ("windowID");
id_x = val_id ("x");
id_y = val_id ("y");
id_clickCount = val_id ("clickCount");
init = true;
}
@@ -55,7 +58,11 @@ namespace lime {
if (event->type != MOUSE_WHEEL) {
alloc_field (object, id_button, alloc_int (event->button));
}
if (event->type != MOUSE_WHEEL && event->type != MOUSE_MOVE) {
alloc_field (object, id_clickCount, alloc_int (event->clickCount));
}
alloc_field (object, id_movementX, alloc_float (event->movementX));
@@ -76,6 +83,7 @@ namespace lime {
eventObject->windowID = event->windowID;
eventObject->x = event->x;
eventObject->y = event->y;
eventObject->clickCount = event->clickCount;
}

View File

@@ -618,7 +618,9 @@ class HTML5Window
Browser.window.addEventListener("mouseup", handleMouseEvent);
}
parent.clickCount = event.detail;
parent.onMouseDown.dispatch(x, y, event.button);
parent.clickCount = 0;
if (parent.onMouseDown.canceled && event.cancelable)
{
@@ -655,7 +657,9 @@ class HTML5Window
event.stopPropagation();
}
parent.clickCount = event.detail;
parent.onMouseUp.dispatch(x, y, event.button);
parent.clickCount = 0;
if (parent.onMouseUp.canceled && event.cancelable)
{

View File

@@ -335,10 +335,14 @@ class NativeApplication
switch (mouseEventInfo.type)
{
case MOUSE_DOWN:
window.clickCount = mouseEventInfo.clickCount;
window.onMouseDown.dispatch(mouseEventInfo.x, mouseEventInfo.y, mouseEventInfo.button);
window.clickCount = 0;
case MOUSE_UP:
window.clickCount = mouseEventInfo.clickCount;
window.onMouseUp.dispatch(mouseEventInfo.x, mouseEventInfo.y, mouseEventInfo.button);
window.clickCount = 0;
case MOUSE_MOVE:
window.onMouseMove.dispatch(mouseEventInfo.x, mouseEventInfo.y);
@@ -785,8 +789,9 @@ class NativeApplication
public var windowID:Int;
public var x:Float;
public var y:Float;
public var clickCount:Int;
public function new(type:MouseEventType = null, windowID:Int = 0, x:Float = 0, y:Float = 0, button:Int = 0, movementX:Float = 0, movementY:Float = 0)
public function new(type:MouseEventType = null, windowID:Int = 0, x:Float = 0, y:Float = 0, button:Int = 0, movementX:Float = 0, movementY:Float = 0, clickCount:Int = 0)
{
this.type = type;
this.windowID = 0;
@@ -795,11 +800,12 @@ class NativeApplication
this.button = button;
this.movementX = movementX;
this.movementY = movementY;
this.clickCount = clickCount;
}
public function clone():MouseEventInfo
{
return new MouseEventInfo(type, windowID, x, y, button, movementX, movementY);
return new MouseEventInfo(type, windowID, x, y, button, movementX, movementY, clickCount);
}
}

View File

@@ -93,6 +93,11 @@ class Window
public var x(get, set):Int;
public var y(get, set):Int;
@:allow(openfl.display.Stage)
@:allow(lime.app.Application)
@:allow(lime._internal.backend.html5.HTML5Window)
private var clickCount:Int = 0;
@:noCompletion private var __attributes:WindowAttributes;
@:noCompletion private var __backend:WindowBackend;
@:noCompletion private var __borderless:Bool;