条形码扫描仪和表单的默认按钮
我的应用程序有一个小问题。我有一个新产品添加对话框窗口。表单上有一个条形码文本框。还有两个按钮 - 取消属性为 True 的“取消”和默认属性为 True 的“保存”。
现在,如果我使条形码文本框处于活动状态并使用条形码扫描仪扫描条形码,它会在条形码末尾添加换行符。还有一个问题 - 它会自动提交表单,因为“保存”按钮接受 ENTER 作为提交键。
如何避免扫描条形码并且末尾有换行符,它不会影响表单的默认按钮?
提前致谢!
I have a small problem with my application. I have a new product adding dialog window. There's a barcode textbox on the form. And two buttons - "Cancel" with Cancel property True and "Save" with Default property True.
Now if I'm making my barcode textbox active and scanning barcode with barcode scanner it adds newline character in the end of the barcode. And there's the problem - it submits the form automatically, because "Save" button accepts ENTER as a submit key.
How can I avoid that scanning barcode and there's newline character at the end, that it does not affect form's default button?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最简单的条形码扫描仪在操作系统看来只是另一个键盘。由于您希望忽略条形码扫描仪发送 Enter 信号的时间,但您希望在用户按下“真实”键盘上的同一键时接受该信号,因此您需要 区分多个键盘。
A barcode scanner, in its simplest form, appears to the OS as just another keyboard. Since you want to ignore when the barcode scanner sends the signal for Enter, but you want to accept it when the user presses the same key on the "real" keyboard, you'll need to distinguish between multiple keyboards.
您可以在文本框中使用
OnEnter
和OnExit
事件来设置“保存”按钮的默认值。我不知道您的“条形码文本框”是否是某种特殊组件,但这适用于
TEdit
。You can use
OnEnter
andOnExit
event on your textbox to set Default of Save button.I don't know if your "barcode textbox" is some kind of special component but this works for a
TEdit
.如果您使用符号扫描仪,我知道您可以使用手册并将后缀字符更改为无。默认情况下,大多数符号扫描仪都配置为自动向数据添加返回字符......
If you are using Symbol scanners I know you can use the manual and change the suffix character to none. By default, most Symbol scanners are configured to automatically add a return character to the data....