diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index 600366a826..6237c407f9 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -335,8 +335,16 @@ wxPG_EX_NO_TOOLBAR_DIVIDER = 0x08000000, /** Show a separator below the toolbar. */ -wxPG_EX_TOOLBAR_SEPARATOR = 0x10000000 +wxPG_EX_TOOLBAR_SEPARATOR = 0x10000000, +/** Allows to take focus on the entire area (on canvas) + even if wxPropertyGrid is not a standalone control. +*/ +wxPG_EX_ALWAYS_ALLOW_FOCUS = 0x00100000, + +/** A mask which can be used to filter (out) all extra styles. +*/ +wxPG_EX_WINDOW_STYLE_MASK = 0x1FFFF000 }; #if wxPG_COMPATIBILITY_1_4 diff --git a/src/propgrid/manager.cpp b/src/propgrid/manager.cpp index 1fc51f4717..384f6017f3 100644 --- a/src/propgrid/manager.cpp +++ b/src/propgrid/manager.cpp @@ -663,7 +663,7 @@ bool wxPropertyGridManager::SetFont( const wxFont& font ) void wxPropertyGridManager::SetExtraStyle( long exStyle ) { wxWindow::SetExtraStyle( exStyle ); - m_pPropGrid->SetExtraStyle( exStyle & 0xFFFFF000 ); + m_pPropGrid->SetExtraStyle( exStyle & wxPG_EX_WINDOW_STYLE_MASK ); #if wxUSE_TOOLBAR if ( (exStyle & (wxPG_EX_NO_FLAT_TOOLBAR|wxPG_EX_MODE_BUTTONS)) && m_pToolbar ) RecreateControls(); diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 0bf663cd0c..2049abf4d0 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -4712,21 +4712,31 @@ void wxPropertyGrid::SetVirtualWidth( int width ) void wxPropertyGrid::SetFocusOnCanvas() { - // To prevent wxPropertyGrid from stealing focus from other controls, - // only move focus to the grid if it was already in one if its child - // controls. - wxWindow* focus = wxWindow::FindFocus(); - if ( focus ) + // By default, to prevent wxPropertyGrid from stealing focus from + // other controls, only move focus to the grid if it was already + // in one of its child controls. + // If wxPG_EX_ALWAYS_ALLOW_FOCUS flag is set then wxPropertyGrid + // can take focus on the entire grid area (canvas) even if focus + // is moved from another control. + if ( HasExtraStyle(wxPG_EX_ALWAYS_ALLOW_FOCUS) ) { - wxWindow* parent = focus->GetParent(); - while ( parent ) + SetFocus(); + } + else + { + wxWindow* focus = wxWindow::FindFocus(); + if ( focus ) { - if ( parent == this ) + wxWindow* parent = focus->GetParent(); + while ( parent ) { - SetFocus(); - break; + if ( parent == this ) + { + SetFocus(); + break; + } + parent = parent->GetParent(); } - parent = parent->GetParent(); } }