Make generic wxDataViewCtrl rows non-selectable

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Anil8753
Experienced Solver
Experienced Solver
Posts: 93
Joined: Sat Jan 16, 2016 5:57 am
Location: India

Make generic wxDataViewCtrl rows non-selectable

Post by Anil8753 »

Is there any way make few wxDataViewItem (row) selectable and few non-selectable. I am using generic wxDataViewCtrl.

I found wxEVT_DATAVIEW_SELECTION_CHANGED triggers after selection change is done. There is no EVT_DATAVIEW_SELECTION_CHANGING event, there I can stop this event.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Make generic wxDataViewCtrl rows non-selectable

Post by doublemax »

I would try to catch the wxEVT_LEFT_DOWN event, do a HitTest() to find the item under the mouse and either consume the event (by doing nothing) or let it pass through (by calling event.Skip().

Unfortunately this can have some bad side-effects, but first check if it works at all.
Use the source, Luke!
Anil8753
Experienced Solver
Experienced Solver
Posts: 93
Joined: Sat Jan 16, 2016 5:57 am
Location: India

Re: Make generic wxDataViewCtrl rows non-selectable

Post by Anil8753 »

Yeah, you are right. I tried the approach given by you. It is working but at the same time, it is opening another set of issues in expand/collapse button functionality.

Now, I am capturing the selection change event and if selected item is not of my interest, I am de-selecting it back. :?
I know it is not a good way, but I have no other way.

It will be good if we can have "Selection Begin" kind of event that can be vetoed. Or virtual Select() method, that I can override and change the behavior. Or a simple API to make the wxDataViewItem non-selectable.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Make generic wxDataViewCtrl rows non-selectable

Post by doublemax »

It will be good if we can have "Selection Begin" kind of event that can be vetoed. Or virtual Select() method, that I can override and change the behavior. Or a simple API to make the wxDataViewItem non-selectable.
All these should be easy enough to implement in the generic version. But that version is only used under MSW, both GTK and OSX have their own native version and the question is if it would be possible there, too.
Use the source, Luke!
Anil8753
Experienced Solver
Experienced Solver
Posts: 93
Joined: Sat Jan 16, 2016 5:57 am
Location: India

Re: Make generic wxDataViewCtrl rows non-selectable

Post by Anil8753 »

I feel in native OSX version it is possible to make a row non-selectable. I am using the generic version on both Win and Mac.
Post Reply