Try MarkDirty in condition to overcome bug, but even MarkDirty do not work for above condition.
Remove SetHint and Repeat above step, IsModified works fine.
Code: Select all
#include<wx/wx.h>
class MyFrame : public wxFrame{
wxPanel *panel;
wxBoxSizer *vbox;
wxTextCtrl *txt,*txt1;
wxDialog *dlg;
void OnChar(wxKeyEvent &event){
event.Skip();
if(event.GetKeyCode()==13){
txt->Navigate(wxNavigationKeyEvent::IsForward);
}else if(event.GetKeyCode()==127){
if(txt->GetStringSelection()==txt->GetValue())txt->MarkDirty();
}
}
void OnFocusOut(wxFocusEvent &event){
event.Skip();
if(txt->IsModified())txt->ChangeValue("Modified.");
else txt->ChangeValue("Not Modified.");
}
public :
MyFrame():wxFrame(NULL,wxID_ANY,"Child Focus"){
panel=new wxPanel(this);
panel->Bind(wxEVT_CHAR_HOOK,&MyFrame::OnChar,this);
vbox=new wxBoxSizer(wxVERTICAL);
txt=new wxTextCtrl(panel,wxID_ANY,wxT(""));
txt->SetHint(wxT("Hint1"));
txt->Bind(wxEVT_KILL_FOCUS,&MyFrame::OnFocusOut,this);
vbox->Add(txt,0,wxEXPAND|wxALL,5);
txt1=new wxTextCtrl(panel,wxID_ANY,wxT(""));
txt1->SetHint(wxT("Hint2"));
vbox->Add(txt1,0,wxEXPAND|wxALL,5);
panel->SetSizer(vbox);
}
};
class MyApp: public wxApp
{
wxFrame* m_frame;
public:
bool OnInit()
{
m_frame = new MyFrame();
m_frame->Show();
return true;
}
};
IMPLEMENT_APP(MyApp);