wx.dataview EVT_DATAVIEW_ITEM_CONTEXT_MENU GetPosition always returns (-1, -1)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

wx.dataview EVT_DATAVIEW_ITEM_CONTEXT_MENU GetPosition always returns (-1, -1)

Adit Panchal-2
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()

Hope someone has some insight.

Thanks!

Adit

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

dvlistctrl.py (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: wx.dataview EVT_DATAVIEW_ITEM_CONTEXT_MENU GetPosition always returns (-1, -1)

Adit Panchal-2
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()

Hope someone has some insight.

Thanks!

Adit

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.dataview EVT_DATAVIEW_ITEM_CONTEXT_MENU GetPosition always returns (-1, -1)

Scott Talbert
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()
>
> Hope someone has some insight.
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.
Reply | Threaded
Open this post in threaded view
|

Re: wx.dataview EVT_DATAVIEW_ITEM_CONTEXT_MENU GetPosition always returns (-1, -1)

Robin Dunn
In reply to this post by Adit Panchal-2
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.

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.dataview EVT_DATAVIEW_ITEM_CONTEXT_MENU GetPosition always returns (-1, -1)

Adit Panchal-2
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 <[hidden email]> 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.

--
Robin Dunn
Software Craftsman
http://wxPython.org

--
You received this message because you are subscribed to a topic in the Google Groups "wxPython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/4M4wCKfaCCE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.