使用鼠标双击时计时器出现问题
我需要区分单击和双击,并且我已将此解决方案与计时器一起使用 msdn.doubleclick
所以我有一个计时器函数,看起来像这样
private void doubleClickTimer_Tick(object sender, EventArgs e)
{
milliseconds += 100;
if (milliseconds >= SystemInformation.DoubleClickTime)
{
doubleClickTimer_.Stop();
if (isDoubleClick)
executeDoubleClick();
else
ExecuteSingleClick();
isFirstClick = true;
isDoubleClick = false;
}
}
,并且工作正常,但是在 ExecuteSingleClick 中我需要 MouseEventArgs e,但我所拥有的只是 EventArgs e 来自 doubleClickTimer 函数,有没有办法从 doubleClickTimer 获取 MouseEventArgs,所以我可以这样写:
ExecuteSingleClick(MouseEventArgs e)
{
MouseButton button = e.button;
....
}
I need to Distinguish Between Clicks and Double-Clicks and I have used this solution with the timer msdn.doubleclick
so I have a Timer function who looks something like this
private void doubleClickTimer_Tick(object sender, EventArgs e)
{
milliseconds += 100;
if (milliseconds >= SystemInformation.DoubleClickTime)
{
doubleClickTimer_.Stop();
if (isDoubleClick)
executeDoubleClick();
else
ExecuteSingleClick();
isFirstClick = true;
isDoubleClick = false;
}
}
and this works ok, but in the ExecuteSingleClick I need the MouseEventArgs e, but all I have is the EventArgs e from the doubleClickTimer function, is there someway to get the MouseEventArgs from the doubleClickTimer so I can write like this:
ExecuteSingleClick(MouseEventArgs e)
{
MouseButton button = e.button;
....
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在启动计时器之前,将其标记属性设置为
mouseeventargs
参数 (e
)。然后,您可以在timer.tick
事件回调中使用它(将其传递给您的execute(double)click 函数)。Before you start the timer, set its tag property to the
mouseeventargs
parameter (e
). You can then use this in thetimer.tick
event callback (pass it to your execute(double)click functions).