This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #531 from atom/wl-activate-pane-on-right-click
Activate panes on any click, not just left click
- Loading branch information
Showing
3 changed files
with
80 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
buildMouseEvent = (type, target, {button, ctrlKey}={}) -> | ||
event = new MouseEvent(type, {bubbles: true, cancelable: true}) | ||
Object.defineProperty(event, 'button', get: -> button) if button? | ||
Object.defineProperty(event, 'ctrlKey', get: -> ctrlKey) if ctrlKey? | ||
Object.defineProperty(event, 'target', get: -> target) | ||
Object.defineProperty(event, 'srcObject', get: -> target) | ||
spyOn(event, "preventDefault") | ||
event | ||
|
||
module.exports.triggerMouseEvent = (type, target, {which, ctrlKey}={}) -> | ||
event = buildMouseEvent(arguments...) | ||
target.dispatchEvent(event) | ||
event | ||
|
||
module.exports.triggerClickEvent = (target, options) -> | ||
events = { | ||
mousedown: buildMouseEvent('mousedown', target, options), | ||
mouseup: buildMouseEvent('mouseup', target, options), | ||
click: buildMouseEvent('click', target, options) | ||
} | ||
|
||
target.dispatchEvent(events.mousedown) | ||
target.dispatchEvent(events.mouseup) | ||
target.dispatchEvent(events.click) | ||
|
||
events | ||
|
||
module.exports.buildDragEvents = (dragged, dropTarget) -> | ||
dataTransfer = | ||
data: {} | ||
setData: (key, value) -> @data[key] = "#{value}" # Drag events stringify data values | ||
getData: (key) -> @data[key] | ||
|
||
Object.defineProperty( | ||
dataTransfer, | ||
'items', | ||
get: -> | ||
Object.keys(dataTransfer.data).map((key) -> {type: key}) | ||
) | ||
|
||
dragStartEvent = buildMouseEvent("dragstart", dragged) | ||
Object.defineProperty(dragStartEvent, 'dataTransfer', get: -> dataTransfer) | ||
|
||
dropEvent = buildMouseEvent("drop", dropTarget) | ||
Object.defineProperty(dropEvent, 'dataTransfer', get: -> dataTransfer) | ||
|
||
[dragStartEvent, dropEvent] | ||
|
||
module.exports.buildWheelEvent = (delta) -> | ||
new WheelEvent("mousewheel", wheelDeltaY: delta) | ||
|
||
module.exports.buildWheelPlusShiftEvent = (delta) -> | ||
new WheelEvent("mousewheel", wheelDeltaY: delta, shiftKey: true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters