wxWidgets:如何在 wxListCtrl 上单击左键? [英] wxWidgets: How to catch left-click on wxListCtrl?

查看:30
本文介绍了wxWidgets:如何在 wxListCtrl 上单击左键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想向 wxListCtrl 添加复选框,这工作正常,但似乎没有 EVT_LIST_ITEM_CLICK 或 EVT_LIST_ITEM_LEFT_CLICK 事件在鼠标单击项目时捕获,以便可以切换图像.有右键和中键单击事​​件,而不是左键单击 - 这意味着您必须中键或右键单击才能勾选/取消勾选列表中的项目.

I want to add checkboxes to a wxListCtrl, and this works fine except there doesn't appear to be an EVT_LIST_ITEM_CLICK or EVT_LIST_ITEM_LEFT_CLICK event to catch when the mouse is clicked on the item so the image can be toggled. There are events for right and middle click, just not left click - which means you have to middle or right click to tick/untick the items in the list.

有谁知道有没有可以使用的左键点击事件?我尝试了 item selected 和 item activate 事件,但这些不报告事件的像素位置,所以我无法使用它们来确定图像是否是被点击的项目的一部分.

Does anyone know whether there is a left-click event you can use? I tried the item selected and item activated events, but these don't report the pixel location of the event, so I can't use them to figure out whether the image was the part of the item clicked.

我基于 wxWidgets wiki 的一些代码,除了它们覆盖了为简单起见,我想避免使用 wxListCtrl 类.我也知道 wxGrid 和其他替代控件,但它们都没有 wxListCtrl 快(而且 wxGrid 复选框看起来也很糟糕.)

I was basing the code on some at the the wxWidgets wiki, except they override the wxListCtrl class which I want to avoid for simplicity. I'm also aware of wxGrid and other alternate controls, but none of them are as quick as the wxListCtrl (and the wxGrid checkboxes look awful too.)

那么,有谁知道如何在 wxListCtrl 中获得左键单击的坐标?

So, does anyone know how you can get the coordinates of left-clicks in a wxListCtrl?

抱歉,wxListCtrl 不是 wxListGrid(对 wxGrid 考虑得太周到了...)

Sorry, wxListCtrl not wxListGrid (was thinking too hard about wxGrid...)

推荐答案

这是我第一次听说 wxListGrid,所以我不知道它有什么功能.但是,通常您总是可以捕获低级鼠标单击事件(例如 EVT_LEFT_UP)并找到鼠标位置下方的项目.

This is the first time ever I hear about wxListGrid so I don't know what is it capable of. However in general you can always catch the low level mouse click events (e.g. EVT_LEFT_UP) and find the item underneath the mouse position.

这篇关于wxWidgets:如何在 wxListCtrl 上单击左键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆