当 Button 对象被释放时获取事件

发布于 2024-12-11 13:33:48 字数 245 浏览 0 评论 0原文

在Windows 7 Phone上,使用Silverlight框架 我想在释放按钮时进行处理。

很容易判断何时按下按钮(Click 事件根据 ClickMode 属性在按下或释放时触发)

我已经使用了事件编辑器提供的所有其他事件(KeyUp、LostFocus、MouseLeave 等)。 )

但我还没有找到关于释放按钮时获取事件的明确信息。

最终,我试图在按下按钮时处理单击与长按的问题

谢谢

On Windows 7 Phone, using Silverlight framework
I'd like to handle when a Button is released.

It's easy to tell when the button is pressed (Click event which is fired either when pressed or when released according to the ClickMode property)

I've played with all the other events provided with the Events editor (KeyUp, LostFocus, MouseLeave etc..)

But I'm yet to find something that is definitive in regards to getting an event when a button is released.

Ultimately, I'm trying to handle doing a click vs a long click when pressing on a button

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

世俗缘 2024-12-18 13:33:48

对于您的情况,KeyUp 只是故事的一半。您还需要处理 KeyDown,在其中保存当前时间,然后将其与 KeyUp 后的当前时间值进行比较,以确定按下是短还是长。您还需要确保跟踪一个特定的按键,以防您的处理程序拦截所有按键。

如果由于某种原因 ClickDown/Up 不起作用,您可以尝试处理 Click 事件,但从 ClickMode 的按下,然后将 ClickMode 更改为在按下处理程序上释放。这个过程虽然并不简单,但却使您有机会实现您正在寻找的按下和计时器释放序列。

For your situation, KeyUp is only half of the story. You also need to handle KeyDown where you will save the current time which you will then compare to the current time value after KeyUp to determine whether the press was short or long. You also need to make sure that you track one particular key in case your handler(s) is/are intercepting all key strokes.

If for some reason ClickDown/Up don't work out you could try handling the Click event but starting with a ClickMode of press, then changing ClickMode to release on the press handler. This process, though not simple, would give you a chance to implement the down-hold and timer-release sequence that you're looking for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文