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
#endif
void SetTextValidator( wxTextValidatorStyle style = wxFILTER_NONE );
wxTextValidator* GetTextValidator() { return (wxTextValidator*)m_textctrl->GetValidator(); }
#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);
// implementation only
void OnOK(wxCommandEvent& event);
Expand().
TripleBorder(wxLEFT | wxRIGHT));
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 )
// 3) buttons if any
wxSizer *buttonSizer = CreateSeparatedButtonSizer(style & (wxOK | wxCANCEL));
if ( buttonSizer )
+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) )
{
void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) )
{
-#if wxUSE_VALIDATORS
- if( Validate() && TransferDataFromWindow() )
+ if ( Validate() && TransferDataFromWindow() )
-#else
- m_value = m_textctrl->GetValue();
-
- EndModal(wxID_OK);
-#endif
- // wxUSE_VALIDATORS
}
void wxTextEntryDialog::SetValue(const wxString& val)
}
void wxTextEntryDialog::SetValue(const wxString& val)
void wxTextEntryDialog::SetTextValidator( wxTextValidatorStyle style )
{
void wxTextEntryDialog::SetTextValidator( wxTextValidatorStyle style )
{
- wxTextValidator validator( style, &m_value );
- m_textctrl->SetValidator( validator );
+ SetTextValidator(wxTextValidator(style));
}
void wxTextEntryDialog::SetTextValidator( const wxTextValidator& validator )
}
void wxTextEntryDialog::SetTextValidator( const wxTextValidator& validator )
m_textctrl->SetValidator( validator );
}
m_textctrl->SetValidator( validator );
}
-#endif
- // wxUSE_VALIDATORS
+#endif // wxUSE_VALIDATORS
// ----------------------------------------------------------------------------
// wxPasswordEntryDialog
// ----------------------------------------------------------------------------
// wxPasswordEntryDialog