开发者

Non-editable text paste target

Users need to be able to paste the contents of an Excel spreadsheet into a grid in my flex application.

I have implemented this using a TextArea with a change event handler that parses the text the th开发者_JS百科e user pastes - splitting it up by newlines and tabs - and adding it to the ArrayCollection that is bound to the grid.

However, it makes no sense for users to be able to manually enter text into the TextArea. How can I prevent them from doing so?

Or: would it make more sense to create my own component that implements IFocusManagerComponent?


[Updated] A bit messy, please cleanup the code before use:

<fx:Script>
    <![CDATA[

        protected function keyDownEvent(e:KeyboardEvent):void
        {
            e.preventDefault();
            switch(e.keyCode)
            {
                case Keyboard.V: 
                    if (e.ctrlKey)
                    {
                        ta.text += "Some dummy " + "\n" +
                            "text pasted in this text area";
                        ta.text += "\n[Keyboard Used to paste]";
                    }
                    break;
                default:
                    e.preventDefault();
            }
        }

        protected function onCreationComplete(event:Event):void
        {
            ta.addEventListener(KeyboardEvent.KEY_DOWN, keyDownEvent);
        }

    ]]>
</fx:Script>

<s:Label text="Press CTRL[V] to see the action"/>
<s:TextArea id="ta"/>

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜