diff --git a/lib/darwin.js b/lib/darwin.js index c0d94a3..74b26cf 100644 --- a/lib/darwin.js +++ b/lib/darwin.js @@ -1,6 +1,7 @@ const AnimationFrameProvider = require('bare-animation-frame') const AppKitApplication = require('bare-app-kit/application') const AppKitEvent = require('bare-app-kit/event') +const FoundationProcessInfo = require('bare-foundation/process-info') const { TYPE, MASK } = AppKitEvent @@ -12,6 +13,7 @@ module.exports = class DarwinPointer { constructor() { this._window = null this._point = null + this._press = 0 } size(view) { @@ -50,6 +52,8 @@ module.exports = class DarwinPointer { } down(view, x, y) { + this._press++ + this._send(TYPE.LEFT_MOUSE_DOWN, view, x, y) } @@ -65,8 +69,8 @@ module.exports = class DarwinPointer { const window = view.window const point = view.convertPointToView(x, y, null) - // Ahead of anything already queued that could take the window off key, as - // the first press in a window that is not key only makes it key. + this._press++ + AppKitApplication.postEvent(this._event(TYPE.LEFT_MOUSE_UP, window, point), true) AppKitApplication.postEvent(this._event(TYPE.LEFT_MOUSE_DOWN, window, point), true) } @@ -96,6 +100,14 @@ module.exports = class DarwinPointer { } _event(type, window, point) { - return AppKitEvent.mouseEvent(type, point.x, point.y, 0, 0, window.windowNumber) + return AppKitEvent.mouseEvent( + type, + point.x, + point.y, + 0, + FoundationProcessInfo.processInfo.systemUptime, + window.windowNumber, + this._press + ) } } diff --git a/package.json b/package.json index 71ed91f..597e427 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "dependencies": { "bare-animation-frame": "^0.1.1", "bare-app-kit": "^0.3.3", + "bare-foundation": "^0.1.1", "bare-ndk": "^0.3.4", "bare-ui-kit-touch": "^0.1.0", "bare-user32": "^0.1.1",