2017-12-10 11 views
0

近代では、どのようにフォーカスできるコンポーネントを作成しますか?ExtJS 6.x近代的なコンポーネントフォーカス

私はtabIndex:0、focusable:trueの両方を試してみました。すべてのドキュメントとコードをhttps://docs.sencha.com/extjs/6.5.2/modern/Ext.mixin.Focusable.htmlで読んだことがありますが、何をしようとしてもコンテナにフォーカスすることができません。

さらに、コンテナのフォーカスが失われたことをどのように検出しますか?いくつかのフォーカス離脱イベントを聞く方法はありますか?

+0

あなたがここに達成するために何をしようとしていますか?あなたはフィドルがありますか? [blur](http://docs.sencha.com/extjs/6.5.2/modern/Ext.Container.html#event-blur)は、コンポーネントがフォーカスを失ったときに発生するイベントです。 –

+0

私はテキストフィールドa、テキストフィールドb、私のコンポーネント、テキストフィールドc。 aをクリックしてTabを一度押すと、textifeld bに移動する必要があります。Tabキーをもう一度押すと、コンポーネントに移動する(または非表示にする)必要があります。私はコンポーネントをフォーカス可能にすることができません。申し訳ありませんフィドル、私は、私はセンチャフィデルアカウントを作成する必要があります。 –

+0

コンポーネントのタイプは?例えば「パネル」? –

答えて

0

sencha fiddleの内側に以下のコードを追加します。

Ext.application({ 
name : 'Fiddle', 

launch : function() { 
Ext.create({ 
xtype: 'panel', 
fullscreen: true, 
bodyPadding: true, // don't want content to crunch against the borders 
title: 'Focusable Elements', 
items: [{ 
    xtype: 'textfield', 
    label: 'field A', 
    tabIndex: 2, 
    listeners: { 
     blur: function (field) { 
      console.log('field A loses focus!') 
     } 
    } 
}, { 
    xtype: 'textfield', 
    label: 'field B', 
    tabIndex: 1, 
    listeners: { 
     blur: function (field) { 
      console.log('field B loses focus!') 
     } 
    } 
}, { 
    xtype: 'panel', 
    title: 'Panel 1', 
    height: 200, 
    html: 'Focus on Me!', 
    tabIndex: 4, 
    focusable: true, 
    layout: { 
     type: 'vbox', 
     align: 'stretch', 
     pack: 'start' 
    }, 
    listeners: { 
     blur: function (panel) { 
      console.log('Panel 1 Lost Focus!'); 
     }, 
     focus: function (panel) { 
      console.log('Panel 1 Got Focus!'); 
     } 
    } 
}, { 
    xtype: 'panel', 
    title: 'Panel 2', 
    height: 200, 
    html: 'Focus on Me!', 
    tabIndex: 5, 
    focusable: true, 
    layout: { 
     type: 'vbox', 
     align: 'stretch', 
     pack: 'start' 
    }, 
    listeners: { 
     blur: function (panel) { 
      console.log('Panel 2 Lost Focus!'); 
     }, 
     focus: function (panel) { 
      console.log('Panel 2 Got Focus!'); 
     } 
    } 
    },{ 
    xtype: 'textfield', 
    label: 'field D', 
    tabIndex: 3, 
    listeners: { 
     blur: function (field) { 
      console.log('field D loses focus!') 
     } 
    } 
}], 
}); 
} 
}); 

フィールドBに焦点を当てて、タブボタンを押してスタート。..

関連する問題