I'm having a real problem hooking onto the events in input field of
type file.

here's the scenaro.

I've made use of the hotkeys plugin for jquery and tweaked it a little
so that hotleys and added a kind of proxy that checks for field focus
and only delegates the event (callback) if no fields have the focus.

The code is straight forward, hook onto all input/select/textarea
field. When every field has focus set a flag to true and when they
lose focus set a flag to false.

The flag is global (but kept in scope) and is checked against by the
event proxy.

here is a snippet of the code:

$(function(){
    var focus=false;

    function onFieldFocus(){focus=true;}

    function onFieldBlur(){focus=false;}

    $('input,select,textarea,file').bind('focus',onFieldFocus);
    $('input,select,textarea,file').bind('blur',onFieldBlur);

    $("input[type='file']").bind('focus',onFieldFocus);
    //$("input[type='file']").bind('blur',onFieldFocus);

    $.fieldFocus=function(){return focus;}

    //  Hotkeys delegate method
    //  Acts as a proxy allowing the shortcut to perform if no field
is focused and sorts out issue with
    //  The keycode value populating a field if given focus
    $.hotkeys.delegate=function(callback){
        //return function(){};

        return function(){
            if(focus==false){
                setTimeout(callback,2);
                return false;
            }
        }
    }
}


The above code is used as follows

$.hotkeys.add('s', {type: 'keydown', propagate: true},
$.hotkeys.delegate(
                function(e){
                    $('#iSearchQuery').trigger('focus');
                }
           ));





The code works very effectively for all fields apart from the file
input field something i cant seem to hook onto.

Is there a solution for this? doesnt have to be in jquery or be part
of the hotkeys script.  Ive seen this sort of thing work in google
mail i.e. when your on the compose view and you are on the attachment
(file) field, hotkeys are disabled. If you move away from the file
field and press a hotkey they work as expected.

How is google doing this? Am i missing something obvious?

I have tested hooking events to a file type field in isolation and
still cant get it to work?



Any body got any solutions here?

Reply via email to