#12706: wxDataViewCtrl does not handle context menu events beyond the list of items

4 views
Skip to first unread message

wxTrac

unread,
Nov 22, 2010, 8:20:23 PM11/22/10
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/12706>

#12706: wxDataViewCtrl does not handle context menu events beyond the list of items
-----------------------+----------------------------------------------------
Reporter: andyburke | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: base | Version:
Keywords: | Blockedby:
Patch: 1 | Blocking:
-----------------------+----------------------------------------------------
If you right-click (on windows) in a wxDataViewCtrl and your mouse is
above an existing item, you will properly receive a
wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU. If, however, there is no item
under your mouse, you will not receive any event. There does not appear
to be a straightforward way to hook up a generic context menu within a
wxDataViewCtrl.

I'd like to propose that if you try to get a context menu in a
wxDataViewCtrl that the event be generated regardless of if there is an
item under the mouse cursor. If there is an item, the event will be
filled out with that item and value as appropriate. If there is no item
under the mouse cursor, there will be no item or value associated with the
event.

I've attached a patch that implements this behavior.

If there is some other way you are supposed to make a context menu work
within a wxDataViewCtrl, please let me know. I did quite a bit of
looking, but it's possible I missed something.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/12706>

wxTrac

unread,
Nov 23, 2010, 7:27:59 AM11/23/10
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/12706#comment:1>

#12706: wxDataViewCtrl does not handle context menu events beyond the list of items

------------------------+---------------------------------------------------
Reporter: andyburke | Owner:
Type: defect | Status: closed


Priority: normal | Milestone:
Component: base | Version:

Resolution: wontfix | Keywords:
Blockedby: | Patch: 1
Blocking: |
------------------------+---------------------------------------------------
Changes (by vadz):

* status: new => closed
* resolution: => wontfix


Comment:

You can always use the standard `EVT_CONTEXT_MENU` for this. Sending
`ITEM_CONTEXT_MENU` with invalid item would be inconsistent with
`EVT_TREE_ITEM_MENU` behaviour so I don't think it would be a good thing.
Also, this would need to be implemented in GTK and OSX versions as well
and while this looks easy for the former I'm not sure if it's possible for
the latter.

So all in all I don't think we should do it but please reopen if I'm
missing something.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/12706#comment:1>

wxTrac

unread,
Nov 23, 2010, 2:36:06 PM11/23/10
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/12706#comment:2>

#12706: t u
------------------------+---------------------------------------------------
Reporter: andyburke | Owner:
Type: defect | Status: closed


Priority: normal | Milestone:
Component: base | Version:

Resolution: wontfix | Keywords:
Blockedby: | Patch: 1
Blocking: |
------------------------+---------------------------------------------------

Comment(by andyburke):

Actually, as far as I can tell, you can't use the standard
EVT_CONTEXT_MENU. Hooking that up on the wxDataViewCtrl only allows it to
work on the column header bar. Hooking it up on the wxDataViewCtrl's main
window (ctrl->GetMainWindow()->Connect(...)) doesn't appear to work at
all. Is there a way to actually hook up EVT_CONTEXT_MENU in a
wxDataViewCtrl that allows the user to right-click anywhere within the
wxDataViewControl and get a context menu?


--
Ticket URL: <http://trac.wxwidgets.org/ticket/12706#comment:2>

wxTrac

unread,
Nov 23, 2010, 2:44:39 PM11/23/10
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/12706#comment:3>

#12706: wxDataViewCtrl does not handle context menu events beyond the list of items

------------------------+---------------------------------------------------
Reporter: andyburke | Owner:
Type: defect | Status: reopened


Priority: normal | Milestone:
Component: base | Version:

Resolution: | Keywords:
Blockedby: | Patch: 0

Blocking: |
------------------------+---------------------------------------------------
Changes (by vadz):

* status: closed => reopened
* resolution: wontfix =>
* patch: 1 => 0


Comment:

I don't know why `EVT_CONTEXT_MENU` doesn't work, it should even without
connecting to the main window as it's a command event which is propagated
upwards. Can you please attach a small patch to the dataview sample
showing that it doesn't work?


--
Ticket URL: <http://trac.wxwidgets.org/ticket/12706#comment:3>

wxTrac

unread,
Nov 23, 2010, 4:39:05 PM11/23/10
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/12706#comment:4>

#12706: wxDataViewCtrl does not handle context menu events beyond the list of items

------------------------+---------------------------------------------------
Reporter: andyburke | Owner:
Type: defect | Status: reopened


Priority: normal | Milestone:
Component: base | Version:

Resolution: | Keywords:
Blockedby: | Patch: 1
Blocking: |
------------------------+---------------------------------------------------
Changes (by andyburke):

* patch: 0 => 1


Comment:

I don't have the examples set up, so it's not easy for me to generate a
working patch against them.

However, I'm attaching a patch that seems to make EVT_CONTEXT_MENU work as
I would expect it to. This patch adds a couple of event.Skip() calls when
the wxDataViewCtrl decides it shouldn't be handling the event (before,
they were just bare returns and the event was eaten).


--
Ticket URL: <http://trac.wxwidgets.org/ticket/12706#comment:4>

wxTrac

unread,
Nov 23, 2010, 6:19:49 PM11/23/10
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/12706#comment:5>

#12706: wxDataViewCtrl does not handle context menu events beyond the list of items

------------------------+---------------------------------------------------
Reporter: andyburke | Owner:
Type: defect | Status: confirmed


Priority: normal | Milestone:
Component: base | Version:

Resolution: | Keywords:
Blockedby: | Patch: 1
Blocking: |
------------------------+---------------------------------------------------
Changes (by vadz):

* status: reopened => confirmed


Comment:

The patch makes sense, thanks, I'll apply it soon.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/12706#comment:5>

wxTrac

unread,
Nov 23, 2010, 6:22:06 PM11/23/10
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/12706#comment:6>

#12706: wxDataViewCtrl does not handle context menu events beyond the list of items

------------------------+---------------------------------------------------
Reporter: andyburke | Owner:
Type: defect | Status: confirmed


Priority: normal | Milestone:
Component: base | Version:

Resolution: | Keywords:
Blockedby: | Patch: 1
Blocking: |
------------------------+---------------------------------------------------

Comment(by andyburke):

Much obliged for the quick response.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/12706#comment:6>

wxTrac

unread,
Nov 23, 2010, 7:42:30 PM11/23/10
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/12706#comment:7>

#12706: wxDataViewCtrl does not handle context menu events beyond the list of items

------------------------+---------------------------------------------------
Reporter: andyburke | Owner:
Type: defect | Status: closed


Priority: normal | Milestone:
Component: base | Version:

Resolution: fixed | Keywords:
Blockedby: | Patch: 1
Blocking: |
------------------------+---------------------------------------------------
Changes (by VZ):

* status: confirmed => closed
* resolution: => fixed


Comment:

(In [66250]) Skip mouse events outside of item area in wxDataViewCtrl.

Don't consume mouse events outside of the area occupied by the items in
the
generic implementation of wxDataViewCtrl as this prevented
wxEVT_CONTEXT_MENU
events from being generated.

Closes #12706.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/12706#comment:7>

Reply all
Reply to author
Forward
0 new messages