CF keyDown 事件(定时)
我的 CF 应用程序需要一个事件,该事件将在用户按下并按住控件 2 秒后触发。我可以使用什么事件,因为 keyDown 事件已被使用。
I need an event for my CF application, that would trigger after user has pressed an held his finger on the control for 2 seconds. What event can i use, since keyDown event is already used.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,KeyDown 与捕获手指按下的时间长度无关。手指的使用与事件
Click
、MouseDown
、MouseUp
和MouseMove
相关。要获得您想要的行为,您应该感兴趣的事件是
MouseDown
和MouseUp
。我建议最好的方法是创建您自己的控件基类。这是我之前制作的一个(未测试,但应该可以让您大致了解要做什么):
基本上,当用户将手指触摸屏幕时,MouseHeldTimer 将以 2 秒的间隔启动。如果用户抬起手指,计时器就会停止。如果用户手指按下的时间超过 2 秒,将触发委托事件
MouseHeldDown
。然后,您可以通过执行以下操作在表单上捕获此事件:或者,如果您只关心表单,则可以仅使用表单的
DoubleClick
事件,因为该事件会在按住鼠标一段时间后触发。第二个或两个。Well, KeyDown is pretty irrelevant for capturing the length of time a finger is pressed. The use of the finger relates to the events
Click
,MouseDown
,MouseUp
andMouseMove
.To get the behaviour you're after, the events you should be interested in are
MouseDown
andMouseUp
.I suggest the best way to do this would be to create your own control base class. Here's one I made earlier (not tested, but should give you a general idea of what to do):
Basically, the MouseHeldTimer will start with an interval of 2 seconds the moment the user touches their finger to the screen. If the user lifts their finger the timer is stopped. If the user's finger is down for longer than 2 seconds, the delegate event
MouseHeldDown
will fire. You can then capture this event on your form by doing the following:Alternatively, if you only care about the form, you can just use the Form's
DoubleClick
event as that will fire after holding the mouse down for a second or two.