selection and context menu
what happens when i try to use context menu and selection?
by Litote0707
HTML
<link rel="stylesheet" href="http://dev.sencha.com/deploy/ext-4.0.2a/resources/css/ext-all.css">
just some text
JavaScript
Ext.onReady(function() {
var selection = undefined;
// Context Menu
var menu = Ext.create('Ext.menu.Menu', {
items: [{
text: 'Copy'
}],
listeners: {
click: function(theMenu, theMenuItem){
alert("On Context menu item:" + theMenu.theSelectedText.toString());
}
}
});
// Bind to contextmenu event listener
Ext.getDoc().on('contextmenu', function(ev) {
selection = window.getSelection();
menu.theSelectedText = window.getSelection().toString();
menu.showAt(ev.getXY());
ev.stopEvent();
});
});