If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
hi,
i recently wrote a dialog that has a couple of wxTextCtrl.The OK button is initially disabled.I would like to know how i can enable it after user has entered atleast one character into the wxTextCtrl.I am trying to achieve this by using
Do not use EVT_UPDATE_UI but EVT_TEXT or EVT_TEXT_ENTER.
A wxUpdateUiEvent is generated on a menu/toolbar item to let you check/uncheck or enable/disable it...
You need to handle the text input event to enable the button.
but EVT_TEXT accepts wxCommandEvent as an argument.But wxCommandEvent doesnt have member function Enable so i wont be able to enable or disable the button.
void MyFrame::OnText(wxCommandEvent &event)
{
wxTextCtrl* myT=(wxTextCtrl*) FindWindow(idTitleCtrl);
// find the button, or maybe just keep it as member of the
// frame?
wxButton* myB=(wxButton*) FindWindow(idbutton);
if(myT && myB){
mtY->GetValue().IsEmpty() ? myB->Enable(false) : myB->Enable();
}
}
Btw, I would keep the controls as members rather then finding them using FindWindow().
Eran
void OnChange(wxCommandEvent& event)
{
//ctrl and button are members so i access them directly
myTextCtrl->GetValue().IsEmpty() ? myButton->Enable(false) : myButton->Enable(true);
}
but this isn't working.any thoughts ?
one question though.I dont see connect method inside wxTextCtrl object.So how come myTextCtrl->Connect(..) is possible ? and why didnt the static event handler worked ?