1. #1
    Ext User
    Join Date
    Oct 2008
    Posts
    195
    Vote Rating
    0
    aj3423 is on a distinguished road

      0  

    Default how to disable the 'backspace' key?

    how to disable the 'backspace' key?


    sometimes I press 'backspace', the browser goes backward , this is very annoying.
    I tried this
    PHP Code:
    (Ext.isIE documentwindow).onkeydown = function(event) {
        var 
    Ext.isIE window.eventevent;

        
    // disable key "backspace" when target is document
        
    var type Ext.isIE e.srcElement.typee.target.type;
        if (
    e.keyCode === && ! type) {
            return 
    false;
        }
    }; 
    the problem is: when I focus a combobox that not editable, then I press 'backspace', the 'type' is 'text', so it won't return false and the browser will refresh.
    Any idea about this?
    Thanks in advance.

  2. #2
    Sencha User steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,649
    Vote Rating
    6
    steffenk has a spectacular aura about steffenk has a spectacular aura about steffenk has a spectacular aura about

      0  

    Default


    it seems noone read the stickies and respect that this is not the place for help requests
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  3. #3
    Ext User
    Join Date
    Oct 2008
    Posts
    195
    Vote Rating
    0
    aj3423 is on a distinguished road

      0  

    Default


    ha, steffenk, I followed you and read the sticky:
    Sticky: **** READ ME FIRST **** - Guidelines, FAQs, Resources etc

    but didn't found anything about the 'backspace' key, and I did some search in forum:
    site:extjs.com backspace , and tried many other key words
    but found nothing.
    Could you give a link?
    Thank you .

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    @steffenk meant the sticky about not asking help in the General Discussion forum!

    I'm moving this thread to the Help forum.

  5. #5
    Ext User
    Join Date
    Oct 2008
    Posts
    195
    Vote Rating
    0
    aj3423 is on a distinguished road

      0  

    Default


    ha, I post in the General Discussion forum, it's a mistake

  6. #6
    Ext JS Premium Member troseberry's Avatar
    Join Date
    Feb 2010
    Location
    Dayton, OH
    Posts
    264
    Vote Rating
    8
    troseberry will become famous soon enough

      0  

    Default


    If you want to stop the browser from going back then you can try something like this.

    Code:
    Ext.EventManager.on(window, 'beforeunload', function(e) {
      e.stopEvent();
    });

  7. #7
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      1  

    Default


    You could check if the element is an <input> that is not disabled or readOnly, e.g.
    Code:
    Ext.EventManager.on(window, 'keydown', function(e, t) {
        if (e.getKey() == e.BACKSPACE && (!/^input$/i.test(t.tagName) || t.disabled || t.readOnly)) {
            e.stopEvent();
        }
    };

  8. #8
    Ext User
    Join Date
    Oct 2008
    Posts
    195
    Vote Rating
    0
    aj3423 is on a distinguished road

      0  

    Default


    oyeah, this is what I want, Thank you troseberry and Condor~

  9. #9
    Ext User
    Join Date
    Oct 2008
    Posts
    195
    Vote Rating
    0
    aj3423 is on a distinguished road

      0  

    Default


    I found another problem, the code is ok for firefox, but in IE8, the
    Ext.EventManager.on(window, 'keydown', function(e, t) {
    doesn't work, I set breakpoint in the function but it never breaks.

  10. #10
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    Strange... Maybe you need to use (Ext.isIE ? document : window) instead of window after all.

Similar Threads

  1. [FIXED] Backspace is not a special or nav key in ComponentEvent
    By rlaferla in forum Ext GWT: Bugs (2.x)
    Replies: 3
    Last Post: 25 Aug 2009, 1:57 PM
  2. Disabling Backspace key
    By randomuser01 in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 30 Oct 2008, 4:56 AM
  3. Keypress event not triggered for backspace key in IE
    By anjelika in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 20 May 2008, 10:48 PM
  4. [2.0a1] TextField and specialkey event concerning backspace key
    By rednix in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 6 Oct 2007, 4:32 PM

Thread Participants: 6

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar