Ensure that wxListCtrl::HitTest finds correct index under qt
This commit is contained in:
@@ -1515,7 +1515,8 @@ void MyListCtrl::OnContextMenu(wxContextMenuEvent& event)
|
|||||||
{
|
{
|
||||||
point = ScreenToClient(point);
|
point = ScreenToClient(point);
|
||||||
}
|
}
|
||||||
ShowContextMenu(point);
|
int flags;
|
||||||
|
ShowContextMenu(point, HitTest(point, flags));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1527,10 +1528,12 @@ void MyListCtrl::OnContextMenu(wxContextMenuEvent& event)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void MyListCtrl::ShowContextMenu(const wxPoint& pos)
|
void MyListCtrl::ShowContextMenu(const wxPoint& pos, long item)
|
||||||
{
|
{
|
||||||
wxMenu menu;
|
wxMenu menu;
|
||||||
|
wxString itemNumber;
|
||||||
|
itemNumber.Printf("Item %ld", item);
|
||||||
|
menu.Append(wxID_ANY, itemNumber);
|
||||||
menu.Append(wxID_ABOUT, "&About");
|
menu.Append(wxID_ABOUT, "&About");
|
||||||
menu.AppendSeparator();
|
menu.AppendSeparator();
|
||||||
menu.Append(wxID_EXIT, "E&xit");
|
menu.Append(wxID_EXIT, "E&xit");
|
||||||
|
@@ -78,7 +78,7 @@ public:
|
|||||||
virtual bool IsItemChecked(long item) const wxOVERRIDE;
|
virtual bool IsItemChecked(long item) const wxOVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ShowContextMenu(const wxPoint& pos);
|
void ShowContextMenu(const wxPoint& pos, long item);
|
||||||
wxLog *m_logOld;
|
wxLog *m_logOld;
|
||||||
void SetColumnImage(int col, int image);
|
void SetColumnImage(int col, int image);
|
||||||
|
|
||||||
|
@@ -910,7 +910,11 @@ long wxListCtrl::FindItem(long WXUNUSED(start), const wxPoint& WXUNUSED(pt), int
|
|||||||
|
|
||||||
long wxListCtrl::HitTest(const wxPoint& point, int &flags, long* ptrSubItem) const
|
long wxListCtrl::HitTest(const wxPoint& point, int &flags, long* ptrSubItem) const
|
||||||
{
|
{
|
||||||
QModelIndex index = m_qtTreeWidget->indexAt(wxQtConvertPoint(point));
|
// Remove the header height as qt expects point relative to the table sub widget
|
||||||
|
QPoint qPoint = wxQtConvertPoint(point);
|
||||||
|
qPoint.setY(qPoint.y() - m_qtTreeWidget->header()->height());
|
||||||
|
|
||||||
|
QModelIndex index = m_qtTreeWidget->indexAt(qPoint);
|
||||||
if ( index.isValid() )
|
if ( index.isValid() )
|
||||||
{
|
{
|
||||||
flags = wxLIST_HITTEST_ONITEM;
|
flags = wxLIST_HITTEST_ONITEM;
|
||||||
|
Reference in New Issue
Block a user