2012-10-31 28 views
6

Tôi hiển thị cửa sổ phương thức với một số điều khiển nhập. Khi tôi bấm phím "tab" nó điều hướng thông qua các điều khiển.Extjs cửa sổ phương thức lấy nét lại các điều khiển

Nếu tôi tiếp tục nhấn "tab", trong một thời điểm nó tập trung các điều khiển phía sau cửa sổ này và thậm chí tôi có thể nhập vào các điều khiển này.

Tôi đang sử dụng ExtJs 4.1

cảm ơn.

+0

Lỗi này vẫn tồn tại trên ExtJS phiên bản 5.0.1.1255. Bất kỳ đề xuất? – dataol

Trả lời

4

Đã giải quyết một số cách giải quyết, làm việc cho tôi, hãy kiểm tra điều này và vui lòng cho tôi biết.

/* ***For activation of Tab Key only to the active panel****/ 


Ext.EventManager.on(Ext.getBody(), 'keydown', focusListenerLogin, Ext.getBody()); 
Ext.EventManager.on(Ext.getBody(), 'keyup', focusListenerLogin, Ext.getBody()); 
Ext.EventManager.on(Ext.getBody(), 'keypress', focusListenerLogin, Ext.getBody()); 
Ext.EventManager.on(Ext.getBody(), 'focusin', focusListenerLogin, Ext.getBody()); 


/***Here the Function is defined.***/ 

function focusListenerLogin(e) { 

if(typeof Ext.WindowManager.getActive() !== 'undefined' && Ext.WindowManager.getActive() !== null) { 
    var activeWinId = Ext.WindowManager.getActive().getId(); 
    var obj = Ext.getCmp(activeWinId); 
    var id = typeof obj.focusEl !=='undefined' ? obj.focusEl.id : obj.id; 
    window.prevFocus; 


    var dom = activeWinId; 
    var components = []; 
    Ext.Array.each(Ext.get(dom).query('*'), function(dom) { 
     var cmp = Ext.getCmp(dom.id); 
     if(cmp && cmp.isVisible()) { 
     if (cmp && cmp.btnEl && cmp.btnEl.focusable()) 
     components.push(cmp.btnEl); 
     else if(cmp && cmp.inputEl && cmp.inputEl.focusable()) 
     components.push(cmp.inputEl); 
     } 
    }); 


    if (typeof obj != 'undefined' && obj.isVisible() && obj.el.id === activeWinId && (typeof e.keyCode!== 'undefined' ? e.keyCode === 9 : true)) { 
     var focused = document.activeElement; 

    if (!focused || focused === document.body){ focused = null;} 
     else if (document.querySelector) focused = document.querySelector(":focus"); 

    if(typeof window.prevFocus !=='undefined' && window.prevFocus !== null && focused !== window.prevFocus && components.length>0 && window.prevFocus.id === components[components.length-1].id) { 

     Ext.getCmp(id).focus(); 
     window.prevFocus = document.activeElement; 
     } 
    else if(components.length==0) { 

     Ext.getCmp(id).focus(); 
     window.prevFocus = document.activeElement; 
    } 
    else 
    window.prevFocus = focused !== null ? focused : window.prevFocus; 
    } 
    return false; 
} 



} 

Logic là

  1. nếu tập trung được đi ra ngoài từ yếu tố cuối cùng của các thành phần cửa sổ sau đó nó sẽ được tái gán cho cái đầu tiên.

  2. nếu cửa sổ không có bất kỳ phần tử có thể lấy tiêu điểm nào thì tiêu điểm sẽ chỉ ở trên cửa sổ.

Vui lòng cho tôi biết nếu đoạn mã này giúp bạn.

Các vấn đề liên quan