Reputation: 102
I need to have access to the clipboard Data on keydown event in Extjs Combobox, to perform some operation.
I tried with window.clipboardData.
Please find the fiddle : https://fiddle.sencha.com/#fiddle/1cc2
Ext.create('Ext.form.field.Tag',{
renderTo:Ext.getBody(),
createNewOnEnter:true,
store:[1,2,3],
enableKeyEvents:true,
listeners:{
keydown:function(combo,e){
if(e.getKey() === e.V && e.ctrlKey){
//get Clipboard data here
combo.preventKeyUpEvent = e.V;
e.stopEvent();
}
}
}
});
Upvotes: 1
Views: 1664
Reputation: 4196
I think you can add paste event listener to your combo (its picker actually) and get clipboard data using methods of ClipboardEvent interface, like this:
combo.getEl().addListener(
'paste',
function(event, element, options) {
var clipboardData = event.browserEvent.clipboardData;
console.log(clipboardData.getData('Text'));
}
);
Upvotes: 4
Reputation: 20224
Not sure what you are doing wrong, but it does work in my IE11 if I add console.log(window.clipboardData)
to your fiddle:
Ext.application({
name : 'Fiddle',
launch : function() {
Ext.create('Ext.form.field.Tag',{
renderTo:Ext.getBody(),
createNewOnEnter:true,
store:[1,2,3],
enableKeyEvents:true,
listeners:{
keydown:function(combo,e){
if(e.getKey() === e.V && e.ctrlKey){
console.log(window.clipboardData);
combo.preventKeyUpEvent = e.V;
e.stopEvent();
}
}
}
});
}
});
I cannot recommend using it, though, since window.clipboardData
is IE only. You should use the W3C clipboard API instead, which is a draft for standardization and already implemented in all recent browsers.
Upvotes: 1