Discussion:
DataViewCtrl: how to get the item under the mouse cursor? (hit test)
Robin Dunn
2014-03-15 04:51:43 UTC
Permalink
Hi,
...
Sorry, I should have mentioned that I'm using 3.0.0, which raises the
same exception as 2.9.5. Is it a known bug?
It looks like but I am not sure.
Sorta. The method wrapper will need to be rewritten (Pythonized) to
return the item and col as a tuple instead of expecting to pass by
reference through the parameters.
--
Robin Dunn
Software Craftsman
http://wxPython.org
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
nepix32
2014-07-01 14:49:09 UTC
Permalink
like but I am not sure.
Sorta. The method wrapper will need to be rewritten (Pythonized) to
return the item and col as a tuple instead of expecting to pass by
reference through the parameters.
I am trying to use DataViewCtrl and I am quite happy with it.
Drag and Drop seems to work as well, but now I struggle to find on which
DataViewItem the drop target is.

As mentioned above, HitTest throws this error:

TypeError: in method 'DataViewCtrl_HitTest', expected argument 4 of type
'wxDataViewColumn *&'

because this is not wrapped yet.

Can I workaround this by providing a memoryview/buffer/pointer myself until
this gets fixed?

With best regards
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Nathan McCorkle
2014-07-09 18:32:52 UTC
Permalink
hmm, I tried passing col.this, as well as trying int(col.this) with no
luck.
:(
I'm trying to compute the DataViewItem that is under the mouse cursor: in
ListCtrl that is done through the HitTest method, but the corresponding
method for DataViewCtrl seems to behave differently, and I haven't
understood how to use it. The following script, using a DataViewListCtrl,
is as far as I've managed to get, can anybody help me? Thank you.
#########################################
import wx
import wx.dataview
pos = view.ScreenToClient(wx.GetMousePosition())
item = view.RowToItem(0)
col = view.GetColumn(0)
print(col.__class__)
# How to get the item under the mouse cursor?
print(view.HitTest(pos, item, col))
#timer.Restart()
app = wx.App()
frame = wx.Frame(None)
view = wx.dataview.DataViewListCtrl(frame, style=wx.dataview.DV_MULTIPLE)
column = view.AppendTextColumn("Text", 0)
view.AppendItem(('Test1', ))
view.AppendItem(('Test2', ))
view.AppendItem(('Test3', ))
timer = wx.CallLater(3000, test)
frame.Centre()
frame.Show()
app.MainLoop()
#########################################
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
nepix32
2014-10-07 10:58:37 UTC
Permalink
Post by Robin Dunn
Sorta. The method wrapper will need to be rewritten (Pythonized) to
return the item and col as a tuple instead of expecting to pass by
reference through the parameters.
In wxPython/trunk/src/dataview.i
<http://trac.wxwidgets.org/browser/wxPython/trunk/src/dataview.i?rev=70457#L2419>
in line 2419 there is already the telling comment:
// TODO: Should probably change this to return the item and col as a
tuple...)
virtual void HitTest( const wxPoint & point, wxDataViewItem &item,
wxDataViewColumn* &column ) const;

As I have no idea whatsoever how to tell SWIG how to do that, can you give
a short explanation what to change in the SWIG-file to get the behaviour in
the comment, or is this very difficult to describe?
With thanks in advance
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Robin Dunn
2014-10-14 00:17:24 UTC
Permalink
Post by Robin Dunn
Sorta. The method wrapper will need to be rewritten (Pythonized) to
return the item and col as a tuple instead of expecting to pass by
reference through the parameters.
In wxPython/trunk/src/dataview.i
<http://trac.wxwidgets.org/browser/wxPython/trunk/src/dataview.i?rev=70457#L2419>
||
// TODO: Should probably change this to return the item and col as a
tuple...)
virtualvoidHitTest(constwxPoint &point,wxDataViewItem
&item,wxDataViewColumn*&column )const;
As I have no idea whatsoever how to tell SWIG how to do that, can you
give a short explanation what to change in the SWIG-file to get the
behaviour in the comment, or is this very difficult to describe?
Thanks for the reminder. I've just implemented it for the CLassic 3.0.2
release.
--
Robin Dunn
Software Craftsman
http://wxPython.org
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Dario Giovannetti
2014-10-14 14:39:14 UTC
Permalink
Post by Robin Dunn
Thanks for the reminder. I've just implemented it for the CLassic
3.0.2 release.
Thank you Robin, does that fix http://trac.wxwidgets.org/ticket/12582 ?
And, if I understand well, would that provide a way to get the current
scroll position of the DataViewCtrl by using the top coordinates of that
window? (It was the only problem left unsolved in
https://groups.google.com/d/msg/wxpython-users/isAboUxaoFs/z9PRJClSPgwJ )
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...