mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 862019 - Add Ctrl-C listener to Variables View for copying items, r=vporof
This commit is contained in:
parent
f097865b72
commit
868038d725
@ -476,6 +476,28 @@ function performTest() {
|
||||
is(gVariablesView.getFocusedItem().visible, false,
|
||||
"The 'someProp7' variable should be hidden.");
|
||||
|
||||
// Part 11: Test that Ctrl-C copies the current item to the system clipboard
|
||||
|
||||
gVariablesView.focusFirstVisibleItem();
|
||||
let copied = promise.defer();
|
||||
let expectedValue = gVariablesView.getFocusedItem().name
|
||||
+ gVariablesView.getFocusedItem().separatorStr
|
||||
+ gVariablesView.getFocusedItem().value;
|
||||
|
||||
waitForClipboard(expectedValue, function setup() {
|
||||
EventUtils.synthesizeKey("C", { metaKey: true }, gDebugger);
|
||||
}, copied.resolve, copied.reject
|
||||
);
|
||||
|
||||
try {
|
||||
yield copied.promise;
|
||||
ok(true,
|
||||
"Ctrl-C copied the selected item to the clipboard.");
|
||||
} catch (e) {
|
||||
ok(false,
|
||||
"Ctrl-C didn't copy the selected item to the clipboard.");
|
||||
}
|
||||
|
||||
yield closeDebuggerAndFinish(gPanel);
|
||||
});
|
||||
}
|
||||
|
@ -25,6 +25,10 @@ Cu.import("resource:///modules/devtools/shared/event-emitter.js");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "devtools",
|
||||
"resource://gre/modules/devtools/Loader.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "clipboardHelper",
|
||||
"@mozilla.org/widget/clipboardhelper;1",
|
||||
"nsIClipboardHelper");
|
||||
|
||||
Object.defineProperty(this, "WebConsoleUtils", {
|
||||
get: function() {
|
||||
return devtools.require("devtools/toolkit/webconsole/utils").Utils;
|
||||
@ -77,11 +81,13 @@ this.VariablesView = function VariablesView(aParentNode, aFlags = {}) {
|
||||
this._onSearchboxInput = this._onSearchboxInput.bind(this);
|
||||
this._onSearchboxKeyPress = this._onSearchboxKeyPress.bind(this);
|
||||
this._onViewKeyPress = this._onViewKeyPress.bind(this);
|
||||
this._onViewKeyDown = this._onViewKeyDown.bind(this);
|
||||
|
||||
// Create an internal scrollbox container.
|
||||
this._list = this.document.createElement("scrollbox");
|
||||
this._list.setAttribute("orient", "vertical");
|
||||
this._list.addEventListener("keypress", this._onViewKeyPress, false);
|
||||
this._list.addEventListener("keydown", this._onViewKeyDown, false);
|
||||
this._parent.appendChild(this._list);
|
||||
this._boxObject = this._list.boxObject.QueryInterface(Ci.nsIScrollBoxObject);
|
||||
|
||||
@ -180,7 +186,9 @@ VariablesView.prototype = {
|
||||
|
||||
this.window.setTimeout(() => {
|
||||
prevList.removeEventListener("keypress", this._onViewKeyPress, false);
|
||||
prevList.removeEventListener("keydown", this._onViewKeyDown, false);
|
||||
currList.addEventListener("keypress", this._onViewKeyPress, false);
|
||||
currList.addEventListener("keydown", this._onViewKeyDown, false);
|
||||
currList.setAttribute("orient", "vertical");
|
||||
|
||||
this._parent.removeChild(prevList);
|
||||
@ -819,6 +827,21 @@ VariablesView.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Listener handling a key down event on the view.
|
||||
*/
|
||||
_onViewKeyDown: function(e) {
|
||||
if (e.keyCode == e.DOM_VK_C) {
|
||||
// Copy current selection to clipboard.
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
let item = this.getFocusedItem();
|
||||
clipboardHelper.copyString(
|
||||
item._nameString + item.separatorStr + item._valueString
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The number of elements in this container to jump when Page Up or Page Down
|
||||
* keys are pressed. If falsy, then the page size will be based on the
|
||||
|
Loading…
Reference in New Issue
Block a user