PDA

View Full Version : How to trap function key in editor grid panel



daniel_82
9 Mar 2011, 4:26 PM
:-/I can trap tab key and enter key in editor grid panel. But I just can not trap all the function key (F1-F12) press.

are there any reason?:-/

BTW I am using following scrip to trap the Tab and enter key in editor grid panel.


var sm = grids_none.getSelectionModel();
sm.onEditorKey = function(field, e) {
var k = e.getKey(), newCell, g = sm.grid, ed = g.activeEditor;
var recordCount = grids_none.getStore().data.length;
if (k == e.ENTER) {}
}

darthwes
9 Mar 2011, 5:47 PM
How hot are you for it? You'll have to tackle some seriously ill problems.

You're ok with overwriting a private function? The specialkey event is installed onto an editor before it is initially rendered. The editor (an Ext.Field implementation of some kind) is basically relaying the event 'specialkey' to you, which is used to detect common navigation keys, as per the documentation. So the function keys wouldn't be those by default...

So you're going to want to add your own event listener to the editor. However, function keys are special to the browsers. They handle the events differently. IE, being especially always and never changing craptacular frog fests of awfulness, doesn't even fire the events, as you would have guessed. You'll want to study the quirksmode page on keys (http://www.quirksmode.org/js/keys.html). And you'd then have to stop the event from the browser, too, so that's especially fun, because if it processes f5 as a refresh, even if it fires the event, that's a blown story, too.

Mostly, I wouldn't even try to capture those keys, as you can always find a different key combination that won't cost a man week to engineer. Happy hunting!