wxWidgets:检测自定义控件上的点击事件 [英] wxWidgets: Detecting click event on custom controls
本文介绍了wxWidgets:检测自定义控件上的点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将点击事件监听器添加到使用wxWidgets制作的自定义控件?自定义控件使用wxWindow作为基础。在事件列表上,我看到
How to add a click event listener to my custom control made with wxWidgets? The custom control uses wxWindow as the base. On the event list I see
wxEVT_LEFT_DOWN
wxEVT_LEFT_UP
wxEVT_LEFT_DCLICK
wxEVT_MIDDLE_DOWN
wxEVT_MIDDLE_UP
wxEVT_MIDDLE_DCLICK
wxEVT_RIGHT_DOWN
wxEVT_RIGHT_UP
wxEVT_RIGHT_DCLICK
wxEVT_MOTION
wxEVT_ENTER_WINDOW
wxEVT_LEAVE_WINDOW
wxEVT_MOUSEWHEEL
但是没有 wxEVT_LEFT_CLICK
或类似的。
推荐答案
通常情况下,没有click事件(如果 wxWidgets - 那里不是
)。点击的动作分为两部分:鼠标向下和鼠标向上。通常,你认为左击事件实际上是在左上事件中处理。
Typically, there is no "click" event (and in the case of wxWidgets - there isn't ). The action of clicking is broken into its two parts: Mouse Down and Mouse Up. Typically what you think of as a "left click" event is actually handled in a "left up" event.
尝试一下:
- 将鼠标悬停在某个按钮上(例如此页上的添加评论按钮)
- 点击鼠标左键并按住
- 在按住鼠标的同时按住鼠标
- 松开鼠标左键
- 发生!
- Hover over a button (such as the "Add Comment" button this page)
- Click the left-mouse button down and hold
- Move the mouse off of the button while holding down
- Release the left-mouse button
- Nothing happens!
这次:
- 将鼠标悬停在同一个按钮上
- 点击
鼠标左键并按住 - 松开鼠标左键
- 您期望的点击操作是由向上事件触发的!
- Hover over the same button
- Click the left-mouse button down and hold
- Release the left-mouse button
- The "click" action you expect is triggered by the up event!
这篇关于wxWidgets:检测自定义控件上的点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文