Search code examples
c++wxwidgets

wxPanel double click to allow user type new title


I have wxNotebook with list of wxPanels (as list of tabs), and I have to allow user to rename tab's title.

Easiest and clearest way, as I think, is to allow by double click just edit title, as double-click on wxGrid allows edit fields value. Is that possible with wxNotebook/wxPanel?

This code allows connect to double click exactly on Panel's tab:

_mainNotebook->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( mainFormImpl::DClickHandling ), NULL, this );

So I can raise window with field for typing new title, and then set this title to page.

But how to let user type it on a fly, like it works with wxGrid? Is it possible? My searching finished with nothing.


Solution

  • There is no support for renaming notebook tabs in place under any of the major platforms, so wxWidgets doesn't support it neither. You can either try to implement it yourself by manually creating and positioning a wxTextCtrl in the correct place (you can look at wxGrid implementation, which is done entirely in wxWidgets itself, for an example of doing it) or use some other book control, e.g. wxListbook which could be made to behave like this as wxListCtrl does support in-place item renaming.