2011-08-09 24 views
2

私のAirアプリケーションでは、フォーカスに2つの問題があります。 実際に、フォームの中をタブキーで移動しようとすると、順序は良くありません。 カーソルがテキスト入力内にあっても、2番目の点ではフォーカス境界線が表示されません。フレックステキスト入力フォーカス

は私のフォームは、カスタムにあるタブに移動し、キー

this.focusManager.activate(); 
this.focusManager.setFocus(this.fdNom); 

私のTextInput CSS

s|TextInput 
{ 
    focusColor: #33CC00; 
    color : #343434; 
    font-weight : normal; 
    font-family: Helvetica ; 
    font-size : 12; 

} 

マイフォーム

<s:Form x="0" y="94" id="foPerso" width="100%" height="100%" 
      includeInLayout="true" includeIn="tb1" 
      backgroundColor="#FFFFF"> 

     <s:layout> 
      <s:FormLayout gap="3" paddingLeft="0"/> 

     </s:layout> 



     <s:HGroup width="100%" gap="3" horizontalAlign="left" resizeMode="noScale" 
        verticalAlign="baseline" > 


      <s:DropDownList id="cbQualite" dataProvider="{DP_PAT_CIVIL}" 
          selectedItem="{getSelectedItem(DP_PAT_CIVIL, objectPatient.paQualPatient)}" 
          change="objectPatient.paQualPatient = event.currentTarget.selectedItem.label"/> 

      <s:FormItem label="Nom" > 
       <s:TextInput id="fdNom" width="200" 
          text="@{objectPatient.paNomU}" 

          /> 
      </s:FormItem> 
      <s:FormItem label="Prénom" > 
       <s:TextInput id="fdPrenom" width="200" text="@{objectPatient.paPrenom}"/> 
      </s:FormItem> 
      <s:DropDownList id="cbDossier1" dataProvider="{DP_PAT_DOS1}" width="118" height="22" tabIndex="3" 
          change="objectPatient.paQualPatient = event.currentTarget.selectedItem.label" 
          /> 

      <s:FormItem label="" > 
       <s:TextInput id="fDossier1" width="90" paddingRight="5" text="@{objectPatient.paDossier1}"/> 
      </s:FormItem> 
     </s:HGroup> 

のコード

の一部の下に検索TitleWindowの成分。

+0

フォームのコードを表示してくださいあなたが何かをいじっている場合を除き、フォーカス枠とタブ順序は自動的に行われるべきです。 –

+0

私のコード – Flex60460

答えて

0

(1)私はおそらくちょうどむしろそれを自分で管理するよりも、Flexはタブ移動を処理できるようにしたい助けるため

感謝。

(2)フォーカススキンを持たないTextInput用のカスタムスキンを使用していますか?

+0

(1)を行う方法 - (2)私のTextInputはカスタムスキンを持っていません。 – Flex60460

+0

(1)がsetFocus()について何かを言うすべてのロジックを取り出すのを助けてくれてありがとう。 Flexには既にタブ処理が適用されています。(2)使用しているフォーカスカラーが背景と十分に対照的でない可能性はありますか? #FF0000を試して、それが見えるかどうか確認してください。 –

+0

解決策が見つかりました。私は私のウィンドウを変更すると、クラスを拡張します(windowwindowのウィンドウの代わりに、すべてのコンポーネントのためのwokをフォーカスします。)助けてくれてありがとう – Flex60460

3

Taborderを操作するには、TextInput tabindexプロパティを使用します。

+0

私はそれをしようとしますが、textinputでのみ動作し、コンボボックスではなく – Flex60460

+0

@isabelle、 ComboBoxではなくDropDownListを使用しています。 –

+0

コンボボックスは編集可能であり、私はしたくないのでコンボボックスは使用しません – Flex60460

0

Flexは、コンポーネントがMXMLで追加された順序に基づいて、自動的にタブ順序を設定します。あなたのMXMLは、次のようになります場合:

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" 
       minWidth="200" minHeight="200"> 

    <s:TextInput id="textInput1" 
       x="0" y="0" 
       text="TEXT INPUT #1" /> 
    <s:ComboBox id="comboBox2" 
       x="0" y="60"> 
    <s:dataProvider> 
     <mx:ArrayList> 
     <fx:String>Red</fx:String> 
     <fx:String>Orange</fx:String> 
     <fx:String>Yellow</fx:String> 
     <fx:String>Blue</fx:String> 
     <fx:String>Green</fx:String> 
     </mx:ArrayList> 
    </s:dataProvider> 
    </s:ComboBox> 
    <s:TextInput id="textInput2" 
       x="0" y="30" 
       text="TEXT INPUT #2" /> 
</s:Application> 

あなたがフィールド間を移動するには、タブボタンを押すと、それは、彼らは彼らのxに基づいて、異なる順序で配置されているにもかかわらず、その後Combobox1、その後TextInput2TextInput1に行きますy座標。これは、これらのコンポーネントがMXMLに表示される順序が原因です。 tabIndexプロパティを設定すると、タブの順序を手動で制御できます。フォーカスのボーダーについては

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" 
       minWidth="200" minHeight="200"> 

    <s:TextInput id="textInput1" 
       x="0" y="0" 
       text="TEXT INPUT #1" 
       tabIndex="1"/> 
    <s:ComboBox id="comboBox2" 
       x="0" y="60" 
       tabIndex="3"> 
    <s:dataProvider> 
     <mx:ArrayList> 
     <fx:String>Red</fx:String> 
     <fx:String>Orange</fx:String> 
     <fx:String>Yellow</fx:String> 
     <fx:String>Blue</fx:String> 
     <fx:String>Green</fx:String> 
     </mx:ArrayList> 
    </s:dataProvider> 
    </s:ComboBox> 
    <s:TextInput id="textInput2" 
       x="0" y="30" 
       text="TEXT INPUT #2" 
       tabIndex="2"/> 
</s:Application> 

、あなたがコンポーネントにカスタムスキンを設定している場合を除き、彼らはまだ彼らの周りはデフォルトの青のフォーカス枠を持っている必要があります。 Comboboxコンポーネントもフォーカスを受け取ることができます。 tabFocusEnabledプロパティをfalseに設定していないことを確認してください。

0

解決策の一部が見つかりましたが、完了するのに手伝ってください。

実際、spark Windowではすべてうまく動作しますが、私はそのようなウィンドウを作成し、フォーカスは見えません。何が間違い?

var wdetcorr:wDetailCorrespondant = new wDetailCorrespondant(); 
      wdetcorr.monIdCorresp = correspDG.selectedItem.crIndex; 

      var wOptions:NativeWindowInitOptions = new NativeWindowInitOptions(); 
      wOptions.systemChrome = NativeWindowSystemChrome.NONE; 
      wOptions.transparent = false; 
      var fnwDetailPatient:FlexNativeWindow = new FlexNativeWindow(wdetcorr, wOptions); 
      fnwDetailPatient.activate(); 

そしてFlexNativeWindowコードは次のとおりです。

package fr.ui.windowSkin 
{ 
import flash.display.NativeWindow; 
    import flash.display.NativeWindowInitOptions; 
    import flash.events.Event; 
    import flash.events.KeyboardEvent; 
    import flash.ui.Keyboard; 

import mx.core.IUIComponent; 
import mx.core.IVisualElement; 
import mx.core.IVisualElementContainer; 
import mx.core.UIComponent; 
import mx.events.*; 
import mx.managers.WindowedSystemManager; 

[Event(name="creationComplete", type="mx.events.FlexEvent")] 

public class FlexNativeWindow extends NativeWindow implements IFlexNativeWindow 
{ 
    private var _systemManager:WindowedSystemManager; 

    private var _content:UIComponent; 

    private var _window:IVisualElementContainer; 

    public function FlexNativeWindow(window:IVisualElementContainer, initOptions:NativeWindowInitOptions = null) 
    { 
     super(initOptions); 


     _window = window; 

     addEventListener(Event.ACTIVATE, windowActivateHandler); 

    } 

    public function addElement(control:IVisualElement):void 
    { 
     _window.addElement(control); 
    } 

    public function removeElement(control:IVisualElement):void 
    { 
     _window.removeElement(control); 
    } 

    private function windowActivateHandler(event:Event):void 
    { 
     event.preventDefault(); 
     event.stopImmediatePropagation(); 
     removeEventListener(Event.ACTIVATE, windowActivateHandler); 

     if (stage) 
     { 
      if (!_systemManager) 
       _systemManager = new WindowedSystemManager(IUIComponent(_window)); 

      stage.addChild(_systemManager); 

      dispatchEvent(new FlexEvent(FlexEvent.CREATION_COMPLETE)); 

      stage.addEventListener(Event.RESIZE, windowResizeHandler); 
      stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownListener); 

     } 
    } 

    private function keyDownListener (e:KeyboardEvent):void { 

     if (e.keyCode == Keyboard.ESCAPE) { 
      stage.nativeWindow.dispatchEvent(new Event("myEventClose", true)); 
      stage.nativeWindow.close(); 
     } 


    } 

    private function windowResizeHandler(event:Event):void 
    { 
     // prise en compte de la valeur mini 
     UIComponent(_window).height = stage.stageHeight; 
     UIComponent(_window).width = stage.stageWidth; 


    } 
} 

}

関連する問題