Fix inplace editing of custom controls for
GTK+ variant of wxDataViewCtrl. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45536 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
|
||||
#if defined(__WXGTK20__)
|
||||
// for testing
|
||||
#define wxUSE_GENERICDATAVIEWCTRL 1
|
||||
// #define wxUSE_GENERICDATAVIEWCTRL 1
|
||||
#elif defined(__WXMAC__)
|
||||
#define wxUSE_GENERICDATAVIEWCTRL 1
|
||||
#else
|
||||
@@ -243,15 +243,18 @@ public:
|
||||
wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner );
|
||||
|
||||
void AcceptChangesAndFinish();
|
||||
void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; }
|
||||
|
||||
protected:
|
||||
void OnChar( wxKeyEvent &event );
|
||||
void OnKillFocus( wxFocusEvent &event );
|
||||
void OnIdle( wxIdleEvent &event );
|
||||
|
||||
private:
|
||||
wxDataViewRenderer *m_owner;
|
||||
wxControl *m_editorCtrl;
|
||||
bool m_finished;
|
||||
bool m_focusOnIdle;
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
@@ -728,10 +728,16 @@ bool wxDataViewRendererBase::StartEditing( unsigned int row, wxRect labelRect )
|
||||
|
||||
m_editorCtrl = CreateEditorCtrl( GetOwner()->GetOwner()->GetMainWindow(), labelRect, value );
|
||||
|
||||
m_editorCtrl->PushEventHandler(
|
||||
new wxDataViewEditorCtrlEvtHandler( m_editorCtrl, (wxDataViewRenderer*) this ) );
|
||||
wxDataViewEditorCtrlEvtHandler *handler =
|
||||
new wxDataViewEditorCtrlEvtHandler( m_editorCtrl, (wxDataViewRenderer*) this );
|
||||
|
||||
m_editorCtrl->PushEventHandler( handler );
|
||||
|
||||
#if defined(__WXGTK20__) && !defined(wxUSE_GENERICDATAVIEWCTRL)
|
||||
handler->SetFocusOnIdle();
|
||||
#else
|
||||
m_editorCtrl->SetFocus();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -773,6 +779,7 @@ bool wxDataViewRendererBase::FinishEditing()
|
||||
BEGIN_EVENT_TABLE(wxDataViewEditorCtrlEvtHandler, wxEvtHandler)
|
||||
EVT_CHAR (wxDataViewEditorCtrlEvtHandler::OnChar)
|
||||
EVT_KILL_FOCUS (wxDataViewEditorCtrlEvtHandler::OnKillFocus)
|
||||
EVT_IDLE (wxDataViewEditorCtrlEvtHandler::OnIdle)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxDataViewEditorCtrlEvtHandler::wxDataViewEditorCtrlEvtHandler(
|
||||
@@ -785,6 +792,18 @@ wxDataViewEditorCtrlEvtHandler::wxDataViewEditorCtrlEvtHandler(
|
||||
m_finished = false;
|
||||
}
|
||||
|
||||
void wxDataViewEditorCtrlEvtHandler::OnIdle( wxIdleEvent &event )
|
||||
{
|
||||
if (m_focusOnIdle)
|
||||
{
|
||||
m_focusOnIdle = false;
|
||||
if (wxWindow::FindFocus() != m_editorCtrl)
|
||||
m_editorCtrl->SetFocus();
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void wxDataViewEditorCtrlEvtHandler::OnChar( wxKeyEvent &event )
|
||||
{
|
||||
switch ( event.m_keyCode )
|
||||
|
Reference in New Issue
Block a user