wxOSX: Rewiring GetBestSize for single line text control again

see #22374
This commit is contained in:
Stefan Csomor
2022-04-30 20:34:28 +02:00
parent 74c0fe6dcc
commit dc2ff0d6b4
2 changed files with 19 additions and 0 deletions

View File

@@ -85,6 +85,9 @@ public :
virtual bool GetNewLineReplacement() wxOVERRIDE;
virtual void SetInternalSelection( long from , long to );
virtual void UpdateInternalSelectionFromEditor( wxNSTextFieldEditor* editor);
virtual wxSize GetBestSize() const wxOVERRIDE;
protected :
NSTextField* m_textField;
long m_selStart;

View File

@@ -1713,6 +1713,22 @@ void wxNSTextFieldControl::SetJustification()
[m_textField setAlignment:align];
}
wxSize wxNSTextFieldControl::GetBestSize() const
{
wxSize sz = wxDefaultSize;
if ( [m_textField respondsToSelector:@selector(sizeToFit)] )
{
NSRect former = [m_textField frame];
[m_textField sizeToFit];
NSRect best = [m_textField frame];
[m_textField setFrame:former];
sz.x = (int)ceil(best.size.width);
sz.y = (int)ceil(best.size.height);
}
return sz;
}
//
//
//