我怎样才能使制表符在Flash中的文本字段? [英] How can I permit tab characters in a textfield in Flash?

查看:109
本文介绍了我怎样才能使制表符在Flash中的文本字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作在一个AS3的Flash游戏,最初取自酒吧code扫描仪输入。它扫描的数据来使用标签来分隔数据段作为一个长字符串。扫描仪作为一个键盘和输入串入一个隐藏的文本框,这样我可以抓住绳子,分裂它拆开来获取数据。

I am working on an AS3 Flash game that initially takes a input from a barcode scanner. The data that it scans comes in as one long string using tabs to separate the data segments. The scanner acts as a keyboard and inputs the string into a hidden textfield so that I can grab the string and split it apart to get the data.

输入和一切伟大工程。那我遇到的问题是,当文本字段接收到一个制表符,而不是插入字符到文本框它强调无论是在文本框。那么接下来的字符集覆盖了已经在文本框。

The input and everything works great. The issue that I am running into is that when the the textfield receives a tab character, instead of inserting the character into the textfield it highlights whatever is in the textfield. Then the next set of characters overwrite what was already in the textfield.

有没有解决这个办法吗?有没有一些方法,使文本框接受标签作为文字字符?我不能改变的吧code分隔的数据串的方式。

Is there any way around this? Is there some way to make the textfield accept the tab as a literal character? I cannot change the way the barcode delimits the data in the string.

感谢您的帮助,您可以给。

Thanks for any help you can give.

推荐答案

(更新解决方案)

这确实是preventabe。你可以用下面的文本(假设文本是文本框)停止它。

That is indeed preventabe. You can stop it with following text (assuming Text is the textfield).

Text.addEventListener(FocusEvent.KEY_FOCUS_CHANGE, TextKeyFocusChange);

private function TextKeyFocusChange(e:FocusEvent):void
{
    e.preventDefault();

    var txt:TextField = TextField(e.currentTarget);

    txt.appendText("\t");
    txt.setSelection(txt.length, txt.length);
}

这篇关于我怎样才能使制表符在Flash中的文本字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆