PDA

View Full Version : [CLOSED] Pasting into a combobox with [SHIFT]+[INS] does not fire triggers



mattpi
6 Sep 2010, 3:41 AM
One of our users has spotted that pasting into a combobox filters and shows the combo options when using [CTRL]+[V], but not the lesser-known alternative [SHIFT]+[INS]. You can see this on the EXT sample pages:

http://dev.sencha.com/deploy/dev/examples/form/combos.html
http://dev.sencha.com/deploy/dev/examples/form/forum-search.html

Is there a techincal reason for this, or can this be tweaked in a future release so they both behave the same? In my mind the two key combinations are equivalent, so should have the same behavior.

Condor
6 Sep 2010, 4:22 AM
The problem is that most browsers don't fire any event for this (you can also paste using the mouse right-click context menu).

You could add extra listeners for cut and paste, but they would only work on IE and Webkit and not on Firefox and Opera.

mattpi
6 Sep 2010, 5:30 AM
Thanks Condor. I will take a look at events - I guess a paste listener would be the only way to catch both of them. As it happens, only working in IE and Webkit is OK for us as we recommending those to our users (and not having this isn't exactly a show-stopper).

I've had a further dig around the forums and found this, so I'll give it a try:

http://www.sencha.com/forum/showthread.php?91370-3.1-Combo-does-not-respond-to-a-right-click-paste&highlight=event+paste

Condor
6 Sep 2010, 5:43 AM
Try:

(function(){
var _initEvents = Ext.form.ComboBox.prototype.initEvents;
Ext.override(Ext.form.ComboBox, {
initEvents: function(){
_initEvents.call(this);
this.el.on({
cut: this.onCutPaste,
paste: this.onCutPaste,
scope: this
});
},
onCutPaste: function(){
delete this.lastKey;
this.dqTask.delay(this.queryDelay);
}
});
})();
(disclaimer: untested code)

mattpi
7 Sep 2010, 6:15 AM
Bingo...that's solved it

I've tested on a PC - it works well on IE8, Chrome and Firefox (a nice surprise). So it's only not working in Opera & IE7 but that's fine in my case.

Thanks for your help Condor