2011-08-09 68 views
2

在我的Air应用程序中,我有两个焦点问题。 事实上,当我尝试使用Tab键移动我的表单时,订单并不好。 第二点,即使光标位于文本输入中,焦点边框也不可见。Flex文本输入焦点

查找下面的代码

部分对于tab键

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

请出示您的窗体的代码,重点边境和tab顺序应该是自动,除非你的东西搞乱完成。 –

+0

在下面查找我的代码 – Flex60460

回答

0

(1)我可能只是让Flex的处理互联,而不是自己管理它。

(2)您是否使用了没有焦点皮肤的TextInput的自定义皮肤?

+0

(1)如何做到这一点 - (2)我的TextInput没有自定义皮肤。感谢您帮助 – Flex60460

+0

(1)取出所有关于setFocus()的逻辑。 Flex已经为您覆盖了Tab键。(2)您使用的对焦颜色可能与背景没有足够的对比度吗?尝试#FF0000,看看是否可见。 –

+0

我找到了解决方案。当我改变我的Windows扩展类(tilewindow的窗口intead,重点放好所有组件,谢谢你的帮助。 – Flex60460

3

使用TextInput tabindex属性来操作taborder。

+0

我试图做到这一点,但它似乎只适用于textinput而不是与combobox – Flex60460

+0

@isabelle,这将是因为你正在使用DropDownList而不是ComboBox。 –

+0

我不使用组合框,因为组合框是可编辑的,我不想 – Flex60460

0

Flex将根据组件添加到MXML中的顺序自动为您设置Tab键顺序。如果你的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> 

当你按下TAB键字段之间移动,它会去TextInput1,然后Combobox1,然后TextInput2即使他们是基于他们的x排列顺序不同,坐标为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这个窗口,所有工作都很好,但是我创建了我的窗口,并且焦点不可见。什么错误?

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; 


    } 
} 

}