Flex 3:在 TextArea 中禁用退格键和删除
我试图阻止任何键更改 Flex TextArea 中的文本。我不想将可编辑属性设置为 false,因为我希望插入符号对于“当前位置”指示器可见,以便用户知道他启动的搜索将从哪里开始。
我添加了change和textInput的事件处理程序,以及执行“event.preventDefault”和“event.stopImmediatePropagation”的keyUp和keyDown。这对于大多数键都适用,但退格键和删除键除外。
有什么办法可以阻止这些人做任何事情吗?
I'm trying to prevent any key from altering the text in a Flex TextArea. I don't want to set the editable property to false, because I want the caret to be visible for a 'current position' indicator, so that the user knows where a search he initiates will start from.
I've added event handlers for change and textInput, as well as keyUp and keyDown that do an 'event.preventDefault' as well as a 'event.stopImmediatePropagation'. This works just fine for most keys, with the exception of backspace and delete.
Is there any way to prevent these from doing anything ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这可能会有所帮助:
This may help:
嗯,似乎它确实在浏览器中不起作用,解决方法怎么样,不确定您是否会喜欢它,但除了粘贴之外似乎还实现了您需要的功能:
Hmmm, seems like it really doesn't work in the browser, how about a workaround, not sure if you'll like it but seems to be achieving what you need apart from pasting:
为什么不直接在更改时重新插入文本呢?
Why not just reinsert the text on change?
我想我已经找到办法了:
在 Flash 中,preventDefault 不适用于关键事件,但它们适用于
改变事件。您可以执行类似于此 https://stackoverflow.com/a/8078910/1927950 的操作来避免任何修改,但仍然保留插入符号。
I think I've figured out a way:
in flash the preventDefault don't work for key event, but they work well for
changing event. You can do something similar to this https://stackoverflow.com/a/8078910/1927950 to avoid any modification but still keep the caret.