I am trying to make the context menu work with wx.dataview but the function GetPosition() always returns (-1, -1) using wxPython Phoenix (Python 3.5). The results are reproducible on both Mac and Windows.
I am using: wxPython-Phoenix==3.0.3.dev2445+ca34d71
I tried binding the event in the demo as well as the following attached sample (modified from the demo) and cannot figure out why it returns this value each time.
I also tried this with both a DataViewCtrl and a DataViewListCtrl with the same results.
Actually, no matter what event I register for, wx.dataview.DataViewEvent always returns (-1, -1) for GetPosition()
I also just noticed that it returns (-1, -1) on wxPython Classic 3.0.2.0 (Python 2.7.11) on the Mac.
I wonder if A. Using the event function properly or B. the event function never worked?
···
On Wednesday, August 17, 2016 at 4:13:19 PM UTC-5, Adit Panchal wrote:
Hello,
I am trying to make the context menu work with wx.dataview but the function GetPosition() always returns (-1, -1) using wxPython Phoenix (Python 3.5). The results are reproducible on both Mac and Windows.
I am using: wxPython-Phoenix==3.0.3.dev2445+ca34d71
I tried binding the event in the demo as well as the following attached sample (modified from the demo) and cannot figure out why it returns this value each time.
I also tried this with both a DataViewCtrl and a DataViewListCtrl with the same results.
Actually, no matter what event I register for, wx.dataview.DataViewEvent always returns (-1, -1) for GetPosition()
Looking at the wxWidgets code, it appears that the position isn't set for wxEVT_DATAVIEW_ITEM_CONTEXT_MENU. It looks like the only thing that is set is the item, so you could call GetItem() to see which item is selected.
···
On Wed, 17 Aug 2016, Adit Panchal wrote:
I also just noticed that it returns (-1, -1) on wxPython Classic 3.0.2.0
(Python 2.7.11) on the Mac.
I wonder if A. Using the event function properly or B. the event function
never worked?
On Wednesday, August 17, 2016 at 4:13:19 PM UTC-5, Adit Panchal wrote:
Hello,
I am trying to make the context menu work with wx.dataview but the
function GetPosition() always returns (-1, -1) using wxPython Phoenix
(Python 3.5). The results are reproducible on both Mac and Windows.
I am using: wxPython-Phoenix==3.0.3.dev2445+ca34d71
I tried binding the event in the demo as well as the following
attached sample (modified from the demo) and cannot figure out why it
returns this value each time.
I also tried this with both a DataViewCtrl and a DataViewListCtrl with
the same results.
Actually, no matter what event I register for,
wx.dataview.DataViewEvent always returns (-1, -1) for GetPosition()
I also just noticed that it returns (-1, -1) on wxPython Classic
3.0.2.0 (Python 2.7.11) on the Mac.
I wonder if A. Using the event function properly or B. the event
function never worked?
Looking at the wxWidgets source code shows that the position is never
set for that event. You can use wx.GetMouseState to get the current
position of the cursor and the sate of the modifier keys.
I tried GetItem() and it works on Windows but not on the Mac, because I think Windows by default selects the item immediately before the event is fired.
My original use case was for wx.PopupMenu, which I thought wouldn’t work without a position, but apparently it does.
I’ll look into wx.GetMouseState for some additional functionality as well.
So do you think this is a bug for that event or is it intended functionality?
Thanks for the quick replies!
Adit
···
On Thu, Aug 18, 2016 at 6:17 PM, Robin Dunn robin@alldunn.com wrote:
Adit Panchal wrote:
I also just noticed that it returns (-1, -1) on wxPython Classic
3.0.2.0 (Python 2.7.11) on the Mac.
I wonder if A. Using the event function properly or B. the event
function never worked?
Looking at the wxWidgets source code shows that the position is never
set for that event. You can use wx.GetMouseState to get the current
position of the cursor and the sate of the modifier keys.