2011-01-29 59 views
0

我有一個登錄表單與各種textInputs和一個提交按鈕。如果您提交正確的登錄憑據,系統將卸載登錄視圖並加載應用程序視圖。相當標準。 不幸的是我注意到這個奇怪的錯誤,如果你用鼠標將鼠標懸停在其中一個textInput框上,然後只用鍵盤填寫表單(並將鼠標停在textInput的頂部),然後選擇提交按鈕並按下空格鍵,即通過鍵盤登錄,無論您做什麼(移動,單擊),鼠標光標都將保留在新視圖中的插入符號,直到找到另一個textInput來撤消遊標狀態。插入文本輸入永不消失

我試圖通過CursorManager做各種各樣的東西,但似乎沒有辦法。我已經嘗試將事件ROLL_OUT或MOUSE_OUT事件分派給textInput,但這也不能解決問題。

我試圖在一個小例子中重現這一點,但一直未能,我意識到讓我更難以幫助。如果有人處理過類似的事情,或者聽到任何可能聽起來相關的指針,我們仍然很樂意聽到。

謝謝!

f

+0

我打算索要樣品。既然你不能創建一個可重複的,它讓我想知道在你的代碼中沒有東西造成這種情況。我可能會建議製作一份你的項目的副本,並慢慢刪除東西,直到它消失。 – JeffryHouser

+0

是...我認爲你是對的。我慢慢地想清楚是什麼讓它發生,儘管我必須承認我仍然不確定它爲什麼會發生。將在一秒內發佈我的發現。 –

回答

0

將我的應用程序剝離到幾乎裸露的骨骼後,我發現textInputs的text屬性綁定到另一個變量的字段。我不知道爲什麼這會產生上述問題,但採取這種約束解決了問題。我希望我能在這件事上做更多的研究,但遺憾的是這已經花費了太多時間。

0

嘗試明確設置焦點到另一個對象嗎?請參閱UIComponent.setFocus()

+0

感謝您的建議。不幸的是,似乎沒有辦法。 –

1

我有完全相同的問題。這裏是我的登錄屏幕視圖:

<fx:Style> 
    @namespace s "library://ns.adobe.com/flex/spark"; 
    @namespace mx "library://ns.adobe.com/flex/mx"; 
    .textInput 
    { 
     showErrorTip : true; 
     showErrorSkin : true; 
    } 
</fx:Style> 
<fx:Declarations> 
    <mx:StringValidator id="usernameValidator" source="{username}" property="text" 
         trigger="{signinButton}" triggerEvent="click" required="true" /> 
    <mx:StringValidator id="passwordValidator" source="{password}" property="text" 
         trigger="{signinButton}" triggerEvent="click" required="true"/> 
</fx:Declarations> 
<fx:Script> 
    <![CDATA[ 
     import info.thwm.appx.model.vo.LoginVO; 
     import info.thwm.appx.view.events.ViewEvent; 

     import mx.validators.Validator; 

     public static const NAME:String = "LoginView"; 
     [Bindable] public var loginVO:LoginVO = new LoginVO(); 

     private function init():void{ 
      focusManager.setFocus(username); 
      sendEvent(ViewEvent.VIEW_CREATED, NAME); 
     } 

     private function sendEvent(type:String, data:Object=null):void{ 
      dispatchEvent(new ViewEvent(type, data)); 
     } 

     private function loginUser(event:MouseEvent = null):void{ 
      var validators:Array = [usernameValidator, passwordValidator]; 
      var errors:Array; 
      errors = Validator.validateAll(validators); 
      if (errors.length == 0){           
       sendEvent(ViewEvent.BTN_LOGIN_CLICK, loginVO); 
      }        
     } 
    ]]> 
</fx:Script> 

<s:Panel width="320" height="230" title="Sign In"> 
<s:layout> 
    <s:VerticalLayout/> 
</s:layout> 
<s:Form id="form1" styleName="formStyle" defaultButton="{signinButton}">   <s:layout> 
      <s:FormLayout paddingLeft="25" gap="-5"/> 
     </s:layout> 
     <s:FormItem label="Username" required="true" skinClass="info.thwm.appx.view.skins.FormItemSkin"> 
      <s:TextInput id="username" text="@{loginVO.username}" styleName="textInput"/> 
     </s:FormItem> 
     <s:FormItem label="Password" required="true" skinClass="info.thwm.appx.view.skins.FormItemSkin"> 
      <s:TextInput displayAsPassword="true" id="password" text="@{loginVO.password}" styleName="textInput"/> 
     </s:FormItem> 
     <s:FormItem> 
      <s:CheckBox label="Remember" id="remember" selected="@{loginVO.remember}"/> 
     </s:FormItem> 
     <s:FormItem> 
      <s:Button label="Sign In" id="signinButton" click="loginUser(event)"/> 
     </s:FormItem> 
    </s:Form> 
    <s:controlBarContent> 
     <s:HGroup width="100%" verticalAlign="middle"> 
      <s:Button label="Register" id="registerButton" click="sendEvent(ViewEvent.BTN_REGISTER_CLICK);" /> 
      <s:Label buttonMode="true" color="#57595A" text="Forgot your username or password?" click="sendEvent(ViewEvent.BTN_PSW_REMINDER_CLICK);"/> 
     </s:HGroup> 
    </s:controlBarContent> 
</s:Panel> 

沒有什麼特殊之處,但如果我選擇的用戶名外地鼠標,然後只用鍵盤其餘的,只要我去下一個視圖鼠標光標變爲輸入插入符號。唯一的解決方法是在下一個view的onCreationComplete事件函數中添加這行「Mouse.cursor = MouseCursor.ARROW」。