Merge pull request #1579 from ShaharMS/develop
Implement `clickCount` on HTML5 and Native.
This commit is contained in:
@@ -30,6 +30,7 @@ namespace lime {
|
|||||||
int windowID;
|
int windowID;
|
||||||
double x;
|
double x;
|
||||||
double y;
|
double y;
|
||||||
|
int clickCount;
|
||||||
|
|
||||||
static ValuePointer* callback;
|
static ValuePointer* callback;
|
||||||
static ValuePointer* eventObject;
|
static ValuePointer* eventObject;
|
||||||
|
|||||||
@@ -4000,7 +4000,7 @@ namespace lime {
|
|||||||
#define _TGAMEPAD_EVENT _OBJ (_I32 _I32 _I32 _I32 _F64)
|
#define _TGAMEPAD_EVENT _OBJ (_I32 _I32 _I32 _I32 _F64)
|
||||||
#define _TJOYSTICK_EVENT _OBJ (_I32 _I32 _I32 _I32 _F64 _F64)
|
#define _TJOYSTICK_EVENT _OBJ (_I32 _I32 _I32 _I32 _F64 _F64)
|
||||||
#define _TKEY_EVENT _OBJ (_F64 _I32 _I32 _I32)
|
#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 _TRECTANGLE _OBJ (_F64 _F64 _F64 _F64)
|
||||||
#define _TRENDER_EVENT _OBJ (_I32)
|
#define _TRENDER_EVENT _OBJ (_I32)
|
||||||
#define _TSENSOR_EVENT _OBJ (_I32 _F64 _F64 _F64 _I32)
|
#define _TSENSOR_EVENT _OBJ (_I32 _F64 _F64 _F64 _I32)
|
||||||
|
|||||||
@@ -622,6 +622,7 @@ namespace lime {
|
|||||||
mouseEvent.button = event->button.button - 1;
|
mouseEvent.button = event->button.button - 1;
|
||||||
mouseEvent.x = event->button.x;
|
mouseEvent.x = event->button.x;
|
||||||
mouseEvent.y = event->button.y;
|
mouseEvent.y = event->button.y;
|
||||||
|
mouseEvent.clickCount = event->button.clicks;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_MOUSEBUTTONUP:
|
||||||
@@ -632,6 +633,7 @@ namespace lime {
|
|||||||
mouseEvent.button = event->button.button - 1;
|
mouseEvent.button = event->button.button - 1;
|
||||||
mouseEvent.x = event->button.x;
|
mouseEvent.x = event->button.x;
|
||||||
mouseEvent.y = event->button.y;
|
mouseEvent.y = event->button.y;
|
||||||
|
mouseEvent.clickCount = event->button.clicks;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_MOUSEWHEEL:
|
case SDL_MOUSEWHEEL:
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace lime {
|
|||||||
static int id_windowID;
|
static int id_windowID;
|
||||||
static int id_x;
|
static int id_x;
|
||||||
static int id_y;
|
static int id_y;
|
||||||
|
static int id_clickCount;
|
||||||
static bool init = false;
|
static bool init = false;
|
||||||
|
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ namespace lime {
|
|||||||
y = 0.0;
|
y = 0.0;
|
||||||
movementX = 0.0;
|
movementX = 0.0;
|
||||||
movementY = 0.0;
|
movementY = 0.0;
|
||||||
|
clickCount = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,6 +48,7 @@ namespace lime {
|
|||||||
id_windowID = val_id ("windowID");
|
id_windowID = val_id ("windowID");
|
||||||
id_x = val_id ("x");
|
id_x = val_id ("x");
|
||||||
id_y = val_id ("y");
|
id_y = val_id ("y");
|
||||||
|
id_clickCount = val_id ("clickCount");
|
||||||
init = true;
|
init = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -55,7 +58,11 @@ namespace lime {
|
|||||||
if (event->type != MOUSE_WHEEL) {
|
if (event->type != MOUSE_WHEEL) {
|
||||||
|
|
||||||
alloc_field (object, id_button, alloc_int (event->button));
|
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));
|
alloc_field (object, id_movementX, alloc_float (event->movementX));
|
||||||
@@ -76,6 +83,7 @@ namespace lime {
|
|||||||
eventObject->windowID = event->windowID;
|
eventObject->windowID = event->windowID;
|
||||||
eventObject->x = event->x;
|
eventObject->x = event->x;
|
||||||
eventObject->y = event->y;
|
eventObject->y = event->y;
|
||||||
|
eventObject->clickCount = event->clickCount;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,4 +94,4 @@ namespace lime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -618,7 +618,9 @@ class HTML5Window
|
|||||||
Browser.window.addEventListener("mouseup", handleMouseEvent);
|
Browser.window.addEventListener("mouseup", handleMouseEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parent.clickCount = event.detail;
|
||||||
parent.onMouseDown.dispatch(x, y, event.button);
|
parent.onMouseDown.dispatch(x, y, event.button);
|
||||||
|
parent.clickCount = 0;
|
||||||
|
|
||||||
if (parent.onMouseDown.canceled && event.cancelable)
|
if (parent.onMouseDown.canceled && event.cancelable)
|
||||||
{
|
{
|
||||||
@@ -655,7 +657,9 @@ class HTML5Window
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parent.clickCount = event.detail;
|
||||||
parent.onMouseUp.dispatch(x, y, event.button);
|
parent.onMouseUp.dispatch(x, y, event.button);
|
||||||
|
parent.clickCount = 0;
|
||||||
|
|
||||||
if (parent.onMouseUp.canceled && event.cancelable)
|
if (parent.onMouseUp.canceled && event.cancelable)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -335,10 +335,14 @@ class NativeApplication
|
|||||||
switch (mouseEventInfo.type)
|
switch (mouseEventInfo.type)
|
||||||
{
|
{
|
||||||
case MOUSE_DOWN:
|
case MOUSE_DOWN:
|
||||||
|
window.clickCount = mouseEventInfo.clickCount;
|
||||||
window.onMouseDown.dispatch(mouseEventInfo.x, mouseEventInfo.y, mouseEventInfo.button);
|
window.onMouseDown.dispatch(mouseEventInfo.x, mouseEventInfo.y, mouseEventInfo.button);
|
||||||
|
window.clickCount = 0;
|
||||||
|
|
||||||
case MOUSE_UP:
|
case MOUSE_UP:
|
||||||
|
window.clickCount = mouseEventInfo.clickCount;
|
||||||
window.onMouseUp.dispatch(mouseEventInfo.x, mouseEventInfo.y, mouseEventInfo.button);
|
window.onMouseUp.dispatch(mouseEventInfo.x, mouseEventInfo.y, mouseEventInfo.button);
|
||||||
|
window.clickCount = 0;
|
||||||
|
|
||||||
case MOUSE_MOVE:
|
case MOUSE_MOVE:
|
||||||
window.onMouseMove.dispatch(mouseEventInfo.x, mouseEventInfo.y);
|
window.onMouseMove.dispatch(mouseEventInfo.x, mouseEventInfo.y);
|
||||||
@@ -785,8 +789,9 @@ class NativeApplication
|
|||||||
public var windowID:Int;
|
public var windowID:Int;
|
||||||
public var x:Float;
|
public var x:Float;
|
||||||
public var y: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.type = type;
|
||||||
this.windowID = 0;
|
this.windowID = 0;
|
||||||
@@ -795,11 +800,12 @@ class NativeApplication
|
|||||||
this.button = button;
|
this.button = button;
|
||||||
this.movementX = movementX;
|
this.movementX = movementX;
|
||||||
this.movementY = movementY;
|
this.movementY = movementY;
|
||||||
|
this.clickCount = clickCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clone():MouseEventInfo
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,11 @@ class Window
|
|||||||
public var x(get, set):Int;
|
public var x(get, set):Int;
|
||||||
public var y(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 __attributes:WindowAttributes;
|
||||||
@:noCompletion private var __backend:WindowBackend;
|
@:noCompletion private var __backend:WindowBackend;
|
||||||
@:noCompletion private var __borderless:Bool;
|
@:noCompletion private var __borderless:Bool;
|
||||||
|
|||||||
Reference in New Issue
Block a user