wxDataViewCtrl - Finish Editing

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

wxDataViewCtrl - Finish Editing

Dr.Claus Teuber
Hi everbody,

I've been having a problem regarding wxDataViewCtrl lately, which also appears in one of the wxwidgets samples.
I'm using wxWidgets 3.0.4 on a windows 7 machine with visual studio 8 and I don't use makefiles.
Let's take a look into the dataview sample. If you left click for example on the element "German Requiem" in "MyMusicTreeModel" and press F2 then you can rename this element. If you then process a left-click the editing will be terminated and the other element will be highlighted.
If you do the same with a right-click you would expect the same behaviour plus a context menu. Unfortunately the editing is not being terminated, but still the context menu appears, which I think is an unnatural behavior.
Since in my application the context menu also has an entry for renaming I even got worse scenarios where several elements where open for editing at the same time.

Everything that I need, is to terminate the editing when a EVT_DATAVIEW_ITEM_CONTEXT_MENU is fired.

This could easily be done with a simple function

void wxDataViewCtrl::FinishEditing(){
   m_clientArea->FinishEditing();
}


Is there a reason why this function does not exist even though the opposite can be done with "wxDataViewCtrl::EditItem"? Or could this be a useful addition?

I am really looking forward to your replies and thank you in advance.

Best regards
Claus

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|

Re: wxDataViewCtrl - Finish Editing

Vadim Zeitlin-4
On Thu, 06 Dec 2018 13:58:28 +0100 Dr.Claus Teuber wrote:

DT> I've been having a problem regarding wxDataViewCtrl lately, which also
DT> appears in one of the wxwidgets samples.
DT> I'm using wxWidgets 3.0.4 on a windows 7 machine with visual studio 8 and I don't use
DT> makefiles.
DT> Let's take a look into the dataview sample. If you left click for example on the element
DT> "German Requiem" in "MyMusicTreeModel" and press F2 then you can rename this element. If
DT> you then process a left-click the editing will be terminated and the other element will be
DT> highlighted.
DT> If you do the same with a right-click you would expect the same behaviour plus a context
DT> menu. Unfortunately the editing is not being terminated, but still the context menu appears,
DT> which I think is an unnatural behavior.

 I agree and I think editing should automatically finish when the right
mouse button is pressed, just as it already happens for the left one.
Moreover, in the native GTK+ version, right clicking does end editing --
although the edit is cancelled and not accepted. This looks wrong too, i.e.
I don't see any reasonable rationale for accepting input on left click but
cancelling it on right click (and what would we supposed to do on middle
click if we did it like this?), so I'd like to change this but I don't see
how to do it, GtkTreeView doesn't seem to provide any way to do it and in
order to call gtk_cell_renderer_stop_editing() we need to have the
GtkCellRenderer to call it on, which we don't, and, anyhow, this would
probably upset the GtkTreeView as its private "edited_column" would get out
of sync with the actual state. So, unfortunately, we'll have to live with a
discrepancy in the behaviour between the generic and GTK+ version: in the
former, I've now implemented accepting the input when right mouse button is
clicked, while the latter continues to discard it, all I did was to at
least suppress some GTK+ errors that we got. Both changes are part of the
PR at https://github.com/wxWidgets/wxWidgets/pull/1052

 Please consider testing it if you can and leave a comment at the URL above
if it doesn't work for you (or maybe even if it does). TIA!


DT> This could easily be done with a simple function
DT>
DT> void wxDataViewCtrl::FinishEditing(){
DT>    m_clientArea->FinishEditing();
DT> }
DT>
DT> Is there a reason why this function does not exist even though the opposite can be done with
DT> "wxDataViewCtrl::EditItem"? Or could this be a useful addition?

 I think this could be a useful addition regardless, but, as usual with
wxDVC, ideally it would be implemented in the GTK and macOS versions too
and I don't know how easy -- or difficult -- would be it be do it there.
All I can say is that if you'd like to submit a pull request implementing
this, it would be welcome.

 FWIW I think that you could also do the same thing implicitly by setting
the focus to something else: the editor will hide on its own when it loses
focus.

 Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/

attachment0 (203 bytes) Download Attachment