1. #1
    Sencha User FlaminPhoenix's Avatar
    Join Date
    May 2009
    Posts
    146
    Vote Rating
    0
    FlaminPhoenix is on a distinguished road

      0  

    Question Preventing an event bubbling to the browser

    Preventing an event bubbling to the browser


    Hi guys,

    I am trying to implement shortcuts in a webpage of mine, and Im forced to use Ctrl+Shift as the key combination... Is there any way to disable IE from taking over?( and getting MY function to execute when I hit Ctrl+S?) Heres my code:

    var binding=new Ext.KeyMap(Ext.get(document),{key:'s',
    ctrl:true,
    shift:true,
    fn:function(){
    alert('Ctrl+Shift+S(Save) Invoked!');
    }
    });

    Also, I have observed that in some cases like Ctrl+R, if my handler function involves showing an alert, the browser doesnt refresh the page... If there are no alert statements within the function, the whole page refreshes.. Is there any workaround for this?


    Also, Is there anyway to prevent the browser from taking over when I hit Alt+F or similar?

    PS: This is going to be implemented in an enterprise level application, so please deter from making the usual statements about my webpage overriding user preferences and how you hate such websites. Thank you in advance
    Last edited by FlaminPhoenix; 29 May 2009 at 11:26 PM. Reason: edit

  2. #2

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,496
    Vote Rating
    44
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    alerts?!

    Do not use the browser alert() method. It blocks the javascript thread.

  4. #4
    Sencha User FlaminPhoenix's Avatar
    Join Date
    May 2009
    Posts
    146
    Vote Rating
    0
    FlaminPhoenix is on a distinguished road

      0  

    Post


    Hi animal, thanks for your quick response...but you pointed me to the extJS API documentation page... any reason in specific? 'cause its the same page which i referred to write my code in the first place...

    I didnt know about the javascript thread block tho...

  5. #5
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,496
    Vote Rating
    44
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    So you didn't see the option which would fix your problem? It's described in the detailed docs for that method if you read it all carefully.

  6. #6
    Sencha User FlaminPhoenix's Avatar
    Join Date
    May 2009
    Posts
    146
    Vote Rating
    0
    FlaminPhoenix is on a distinguished road

      0  

    Post


    Quote Originally Posted by Animal View Post
    So you didn't see the option which would fix your problem? It's described in the detailed docs for that method if you read it all carefully.
    My bad, I seem to have forgotten to post the fact that stopEvent:true, doesnt seem to work at all. This is the reason why I decided to post my problem here at the forums in the first place... IE goes about its own merry way(refreshes the page after executing the function defined below) even though I have :

    binding.addBinding({
    key:'r',
    ctrl:true,
    stopEvent:true,
    fn:function(){
    FxMessage('Ctrl+R(Reset) Invoked!');
    }
    });

    FX Message is a local function. It puts the string passed to it in a window and slides it in and out of view....



    Thanks in advance animal
    No one stands taller than the last man standing

  7. #7
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,496
    Vote Rating
    44
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    The stopEvent config has no effect?

    Hmm. Let me check it.

  8. #8
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,496
    Vote Rating
    44
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Looks like Ctrl/R just can't be stopped.

  9. #9
    Sencha User FlaminPhoenix's Avatar
    Join Date
    May 2009
    Posts
    146
    Vote Rating
    0
    FlaminPhoenix is on a distinguished road

      0  

    Thumbs up


    hi all,

    I have spent a day trying to get around this problem, and it still doesnt seem to work... Any more ideas from anyone??..
    No one stands taller than the last man standing

  10. #10
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,496
    Vote Rating
    44
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Looks like CTRL/R just can't be stopped.

    There's no guarantee that Javascript code gets full control of the browser.

    In fact disabling refresh is a bit antisocial. I'm not surprised it's not allowed.

Thread Participants: 1