RichEdit 中拦截 TAB 键
这里有很多类似的问题,但我找不到我的问题的答案。
我有一个 TRichEdit
并希望在用户按 Tab 时实现一些自定义行为。我将丰富编辑的 WantTabs
属性设置为 True
并尝试在 OnKeyDown
中添加我的自定义行为,效果很好,但不幸的是,此后“正常的”制表符行为也会被执行(在编辑中插入制表符)。我尝试在事件处理程序中将 Key
设置为 0
,但这没有帮助。
如何防止执行“正常”选项卡行为?
There are lot of similar questions on here, but I couldn't find an answer for my problem.
I have a TRichEdit
and want to implement some custom behaviour when the user presses Tab. I set the rich edit's WantTabs
property to True
and tried to add my custom behaviour in OnKeyDown
, which works fine, but unfortunately after that the "normal" tab behaviour is executed as well (inserting a tab character in the edit). I tried setting Key
to 0
in the event handler but that doesn't help.
How can I prevent the "normal" tab behaviour from being executed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请改用
OnKeyPress
事件:或者,如果您确实需要使用
OnKeyDown
事件,只需删除按键消息即可:Use the
OnKeyPress
event instead:Alternatively, if you really need to use the
OnKeyDown
event, simply remove the key messages: