Don't set initial label in wxNativeWindow on OS X
Differentiate between setting the label from SetLabel() and from
SetPeer() (i.e. initially), because some native controls shouldn't have
an empty string set as their intitial value.
Override SetInitialSize() to be empty for wxNativeWindow in order to
prevent label-setting issues when an unknown, caller-controlled native
widget is attached. Reverts db9baf9aa5
,
which was the previous attempt to fix this, but was causing too many
problems elsewhere.
This commit is contained in:
@@ -288,6 +288,8 @@ public :
|
|||||||
#if wxUSE_MARKUP && wxOSX_USE_COCOA
|
#if wxUSE_MARKUP && wxOSX_USE_COCOA
|
||||||
virtual void SetLabelMarkup( const wxString& WXUNUSED(markup) ) { }
|
virtual void SetLabelMarkup( const wxString& WXUNUSED(markup) ) { }
|
||||||
#endif
|
#endif
|
||||||
|
virtual void SetInitialLabel( const wxString& title, wxFontEncoding encoding )
|
||||||
|
{ SetLabel(title, encoding); }
|
||||||
|
|
||||||
virtual void SetCursor( const wxCursor & cursor ) = 0;
|
virtual void SetCursor( const wxCursor & cursor ) = 0;
|
||||||
virtual void CaptureMouse() = 0;
|
virtual void CaptureMouse() = 0;
|
||||||
|
@@ -30,6 +30,27 @@
|
|||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
class wxNativeWidgetCocoaImpl : public wxWidgetCocoaImpl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxNativeWidgetCocoaImpl(wxWindowMac* peer, WXWidget w) : wxWidgetCocoaImpl(peer, w)
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual void SetInitialLabel(const wxString& WXUNUSED(title), wxFontEncoding WXUNUSED(encoding)) wxOVERRIDE
|
||||||
|
{
|
||||||
|
// Don't set initial label, because the control was created by the
|
||||||
|
// caller and is already fully setup. And some controls (notably
|
||||||
|
// NSPathControl) assert if an unexpected string value, such as an empty
|
||||||
|
// string, is set.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wxNativeWindow::Create(wxWindow* parent,
|
wxNativeWindow::Create(wxWindow* parent,
|
||||||
wxWindowID winid,
|
wxWindowID winid,
|
||||||
@@ -62,7 +83,7 @@ wxNativeWindow::Create(wxWindow* parent,
|
|||||||
// As wxWidgets will release the view when this object is destroyed, retain
|
// As wxWidgets will release the view when this object is destroyed, retain
|
||||||
// it here to avoid destroying the view owned by the user code.
|
// it here to avoid destroying the view owned by the user code.
|
||||||
[view retain];
|
[view retain];
|
||||||
SetPeer(new wxWidgetCocoaImpl(this, view));
|
SetPeer(new wxNativeWidgetCocoaImpl(this, view));
|
||||||
|
|
||||||
// It doesn't seem necessary to use MacPostControlCreate() here as we never
|
// It doesn't seem necessary to use MacPostControlCreate() here as we never
|
||||||
// change the native control geometry here.
|
// change the native control geometry here.
|
||||||
|
@@ -353,8 +353,7 @@ void wxWindowMac::SetPeer(wxOSXWidgetImpl* peer)
|
|||||||
if ( !m_hasFont )
|
if ( !m_hasFont )
|
||||||
DoSetWindowVariant( m_windowVariant );
|
DoSetWindowVariant( m_windowVariant );
|
||||||
|
|
||||||
if ( !m_label.empty() )
|
GetPeer()->SetInitialLabel( wxStripMenuCodes(m_label, wxStrip_Mnemonics), GetFont().GetEncoding() ) ;
|
||||||
GetPeer()->SetLabel( wxStripMenuCodes(m_label, wxStrip_Mnemonics), GetFont().GetEncoding() ) ;
|
|
||||||
|
|
||||||
// for controls we want to use best size for wxDefaultSize params )
|
// for controls we want to use best size for wxDefaultSize params )
|
||||||
if ( !GetPeer()->IsUserPane() )
|
if ( !GetPeer()->IsUserPane() )
|
||||||
|
Reference in New Issue
Block a user