Fix wxTextEntryDialog::GetValue() when using SetTextValidator().
Associating a validator with the text control in wxTextEntryDialog resulted in GetValue() always returning an empty string which was completely unexpected. Fix this by setting the value string manually to avoid interfering with any possibly used validators. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73774 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -69,8 +69,10 @@ public:
|
||||
#endif
|
||||
void SetTextValidator( wxTextValidatorStyle style = wxFILTER_NONE );
|
||||
wxTextValidator* GetTextValidator() { return (wxTextValidator*)m_textctrl->GetValidator(); }
|
||||
#endif
|
||||
// wxUSE_VALIDATORS
|
||||
#endif // wxUSE_VALIDATORS
|
||||
|
||||
virtual bool TransferDataToWindow();
|
||||
virtual bool TransferDataFromWindow();
|
||||
|
||||
// implementation only
|
||||
void OnOK(wxCommandEvent& event);
|
||||
|
@@ -105,11 +105,6 @@ bool wxTextEntryDialog::Create(wxWindow *parent,
|
||||
Expand().
|
||||
TripleBorder(wxLEFT | wxRIGHT));
|
||||
|
||||
#if wxUSE_VALIDATORS
|
||||
wxTextValidator validator( wxFILTER_NONE, &m_value );
|
||||
m_textctrl->SetValidator( validator );
|
||||
#endif // wxUSE_VALIDATORS
|
||||
|
||||
// 3) buttons if any
|
||||
wxSizer *buttonSizer = CreateSeparatedButtonSizer(style & (wxOK | wxCANCEL));
|
||||
if ( buttonSizer )
|
||||
@@ -134,19 +129,26 @@ bool wxTextEntryDialog::Create(wxWindow *parent,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxTextEntryDialog::TransferDataToWindow()
|
||||
{
|
||||
m_textctrl->SetValue(m_value);
|
||||
|
||||
return wxDialog::TransferDataToWindow();
|
||||
}
|
||||
|
||||
bool wxTextEntryDialog::TransferDataFromWindow()
|
||||
{
|
||||
m_value = m_textctrl->GetValue();
|
||||
|
||||
return wxDialog::TransferDataFromWindow();
|
||||
}
|
||||
|
||||
void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
#if wxUSE_VALIDATORS
|
||||
if ( Validate() && TransferDataFromWindow() )
|
||||
{
|
||||
EndModal( wxID_OK );
|
||||
}
|
||||
#else
|
||||
m_value = m_textctrl->GetValue();
|
||||
|
||||
EndModal(wxID_OK);
|
||||
#endif
|
||||
// wxUSE_VALIDATORS
|
||||
}
|
||||
|
||||
void wxTextEntryDialog::SetValue(const wxString& val)
|
||||
@@ -167,8 +169,7 @@ void wxTextEntryDialog::SetTextValidator( long style )
|
||||
|
||||
void wxTextEntryDialog::SetTextValidator( wxTextValidatorStyle style )
|
||||
{
|
||||
wxTextValidator validator( style, &m_value );
|
||||
m_textctrl->SetValidator( validator );
|
||||
SetTextValidator(wxTextValidator(style));
|
||||
}
|
||||
|
||||
void wxTextEntryDialog::SetTextValidator( const wxTextValidator& validator )
|
||||
@@ -176,8 +177,7 @@ void wxTextEntryDialog::SetTextValidator( const wxTextValidator& validator )
|
||||
m_textctrl->SetValidator( validator );
|
||||
}
|
||||
|
||||
#endif
|
||||
// wxUSE_VALIDATORS
|
||||
#endif // wxUSE_VALIDATORS
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxPasswordEntryDialog
|
||||
|
Reference in New Issue
Block a user