PopupMenuItem Click 和 MouseOver 的区别
当菜单项有一个子菜单时,鼠标悬停在展开子菜单时会触发单击事件。
这个点击事件和用户实际点击有什么区别吗?
我使用 TPopupMenu 作为 cxButton 的下拉属性。
编辑 德尔福2007
When a Menu Item has a sub Menu hovering the mouse expands the sub-menu it fires a click event.
Is there any difference between this click event and if the user actually clicks?
I'm using a TPopupMenu as dropdown property of a cxButton.
EDIT
Delphi 2007
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不确定这是否适用于 D2007;在 D7 中也是如此。你可以尝试以下方法吗?
说明:悬停触发的OnClick是由WM_INITMENUPOPUP发起的,而鼠标点击触发的OnClick是由这个WM_COMMAND发起的。
这取决于已初始化的 Menus.pas。但据我从 Delphi 单元初始化顺序 了解到,即使您将此代码放入辅助单元中。
Not sure this will work with D2007; it does in D7. Can you try the following?
Explanation: The OnClick which is triggered by a hover is initiated by a WM_INITMENUPOPUP, but the OnClick which is triggered by a mouse click is initiated by this WM_COMMAND.
This depends on Menus.pas already having been initialized. But as I understand from Delphi unit initialization order, that is guaranteed even if you put this code in an auxiliary unit.
那么,如果用户实际单击带有子菜单项的 MenuItem,则不会触发 OnClick 事件。因此,区别在于:
如果菜单项具有链接操作:
Well, if the user actually clicks a MenuItem with sub menu items, the OnClick event is not fired. So the distinction is made by:
And if the menu item has a linked action:
不,没有。如果用户单击该项目或将其悬停在该项目上,则会触发相同的 OnClick 事件。
我已经针对 Delphi 2009 检查了这一点。
No there isn't. If the user clicks the item or hover it, the same OnClick event is fired.
I've checked this for Delphi 2009.