【问题标题】:Flex TextInput does not fire FocusIn event when editing is disabled禁用编辑时,Flex TextInput 不会触发 FocusIn 事件
【发布时间】:2012-01-20 12:42:48
【问题描述】:

我一直在尝试将 Flex 4.6 中的标注控件用于移动应用程序而不是组合。场景是您有一个 TextInput,它会提示用户“选择 ...”,当您触摸它 (iPad) 时,它会接收焦点并填充一个标注以允许您从列表中进行选择。

这在 Mac 上运行时效果很好,但是当我部署到 iPad 时,focusIn 事件似乎只有在 TextInput 控件打开了编辑时才会触发。这违背了目的,因为软键盘会弹出,并且当我真的只想从列表中选择它时,控件是可编辑的。

TextInput 控件的代码是;

<s:TextInput id="txtLocation" x="171" y="149" 
            enabled="false" editable="false" 
            height="38" fontSize="16" 
            prompt="Select ..." 
            focusEnabled="true"
            focusIn="depotCallout.open(this.txtLocation,true)"/>

此代码也在 Holly Schinsky 的示例应用中,演示了如何使用标注。任何想法将不胜感激。

【问题讨论】:

    标签: apache-flex flash-builder textinput callout


    【解决方案1】:

    好吧,我有点固执己见,不是专业的编码员,但我找到了答案。

            <?xml version="1.0" encoding="utf-8"?>
        <!-- mobile_keyboard/views/UseNextLikeTab.mxml -->
        <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
                xmlns:s="library://ns.adobe.com/flex/spark" title="Change Focus">
            <fx:Declarations>
                <!-- Place non-visual elements (e.g., services, value objects) here -->
            </fx:Declarations>
    
            <s:layout>
                <s:VerticalLayout paddingTop="10" paddingLeft="10" paddingRight="10"/>
            </s:layout>
    
            <fx:Script>
                <![CDATA[
                    private function changeField(ti:TextInput):void {
                        // Before changing focus to a new control, set the stage's focus to null:
                        stage.focus = null;
    
                        // Set focus on the TextInput that was passed in:
                        ti.setFocus();
                    }
                ]]>
            </fx:Script>
    
            <s:HGroup>
                <s:Label text="1:" paddingTop="15"/>
                <s:TextInput id="ti1" prompt="First Name"
                             width="80%"
                             returnKeyLabel="next" 
                             enter="changeField(ti2)"/>     
            </s:HGroup>
            <s:HGroup>
                <s:Label text="2:" paddingTop="15"/>
                <s:TextInput id="ti2" prompt="Middle Initial" 
                             width="80%"
                             returnKeyLabel="next" 
                             enter="changeField(ti3)"/>
            </s:HGroup>
            <s:HGroup>
                <s:Label text="3:" paddingTop="15"/>
                <s:TextInput id="ti3" prompt="Last Name" 
                             width="80%"
                             returnKeyLabel="next" 
                             enter="changeField(ti1)"/>
            </s:HGroup>
    
        </s:View>
    

    我在这个页面上找到了代码:Adobe fex 4.6

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-13
      • 1970-01-01
      • 2011-10-07
      • 2017-06-10
      • 2011-03-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多