加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex(Flash Builder)中,ComboBox禁止用户自动编辑的简易方法

发布时间:2020-12-15 04:07:01 所属栏目:百科 来源:网络整理
导读:使用的是Flex4,据说Flex3使用的是label 一开始在网上搜索资料,说要使用“皮肤”,作为一个初学者,不懂~~~ 有一个简单的小技巧 Flex中Combo源码 * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */publi

使用的是Flex4,据说Flex3使用的是label


一开始在网上搜索资料,说要使用“皮肤”,作为一个初学者,不懂~~~


有一个简单的小技巧

Flex中Combo源码

*  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 1.5
 *  @productversion Flex 4
 */
public class ComboBox extends DropDownListBase implements IIMESupport
{
    //--------------------------------------------------------------------------
    //
    //  Skin Parts
    //
    //--------------------------------------------------------------------------   
    /**
     *  Optional skin part that holds the input text or the selectedItem text.
     * 
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    [SkinPart(required="false")]
    public var textInput:TextInput;    //   这里,使用的是一个输入框
            
    //--------------------------------------------------------------------------
    //
    //  Class mixins
    //
    //--------------------------------------------------------------------------
            
    /**
     *  @private
     *  Placeholder for mixin by ComboBoxAccImpl.
     */
    mx_internal static var createAccessibilityImplementation:Function;
            
    /**
     *  Constructor.
     * 
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    public function ComboBox()
    {
        super();
                
        addEventListener(KeyboardEvent.KEY_DOWN,capture_keyDownHandler,true);
        allowCustomSelectedItem = true;
    }

也就是说,可以利用输入框的editable来限定是否能够输入

<!-- 下拉选框中有一个小技巧来禁止用户手动输入,也可以使用“皮肤”的方式,但是相对麻烦一些 -->
        <s:ComboBox id="selectUnit" x="117" y="154" width="174" change="comboBoxClick()"
                    dataProvider="{_unitSelectList}" enabled="true" prompt="choose a number"
                    selectedIndex="-1" creationComplete="selectUnit.textInput.editable = false"/>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读