开发者

Flash builder 4.5: Disable shortcut keys in tree component

开发者 https://www.devze.com 2023-04-09 08:48 出处:网络
When we have the focus on a item in TREE component in flash builder app, and start to press keys in our keyboard, the focus changes to the item that begins with the letter that we just push. For examp

When we have the focus on a item in TREE component in flash builder app, and start to press keys in our keyboard, the focus changes to the item that begins with the letter that we just push. For example, we have the next data in our Tree component "fruits":

Fruits --Apple --Orange --Peach

if we have a focus on the item 'Peach' and pressing 'a' on your keyboard, the focus will automatically move to the item 'Apples'.

I NEED DISABLE THIS FUNCTION

I made some attempts with event.Preventdefault() function, called from different triggers such as 'textInput' 'keyDown' 'keyFocusChange' and others but did not get the results I need. I paste some code to explain better

protected function tree2_keyDownHandler(event:KeyboardEvent):void
{
// TODO Auto-generated method stub
trace('press key!');
event.preventDefault();
}

<mx:Tree id="tree2" keyDo开发者_开发问答wn="tree2_keyDownHandler(event)" />

Thanks in advance


Try
mx:Tree id="tree2" selectable="false"


package yourPackage {

    import flash.events.KeyboardEvent;
    import flash.events.TimerEvent;
    import mx.controls.Tree;

    public class YourNewTree extends Tree {

        public var keyNav:Boolean = false;

        override protected function keyDownHandler(event:KeyboardEvent) : void {
            if(keyNav){super.keyDownHandler(event);}
        }

        override protected function keyUpHandler(event:KeyboardEvent) : void {
            if(keyNav){ super.keyUpHandler(event); }
        }
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号