Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions lib/darwin.js
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -12,6 +13,7 @@ module.exports = class DarwinPointer {
constructor() {
this._window = null
this._point = null
this._press = 0
}

size(view) {
Expand Down Expand Up @@ -50,6 +52,8 @@ module.exports = class DarwinPointer {
}

down(view, x, y) {
this._press++

this._send(TYPE.LEFT_MOUSE_DOWN, view, x, y)
}

Expand All @@ -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)
}
Expand Down Expand Up @@ -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
)
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading