ENH: StateHandler as wxEvtHandler and attach child

Change-Id: I1183b97983907f297888d81809be60e3016ae305
This commit is contained in:
chunmao.guo 2022-08-09 11:03:14 +08:00 committed by Lane.Wei
parent 2c99301fe6
commit b96ca57fde
4 changed files with 72 additions and 39 deletions

View file

@ -61,18 +61,7 @@ void SpinInput::Create(wxWindow *parent,
text_ctrl->SetBackgroundColour(background_color.colorForStates(state_handler.states()));
text_ctrl->SetForegroundColour(text_color.colorForStates(state_handler.states()));
text_ctrl->SetInitialSize(text_ctrl->GetBestSize());
text_ctrl->Bind(wxEVT_SET_FOCUS, [this](auto &e) {
e.SetId(GetId());
ProcessEventLocally(e);
});
text_ctrl->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
e.SetId(GetId());
ProcessEventLocally(e);
});
text_ctrl->Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) {
e.SetId(GetId());
ProcessEventLocally(e);
});
state_handler.attach_child(text_ctrl);
text_ctrl->Bind(wxEVT_KILL_FOCUS, &SpinInput::onTextLostFocus, this);
text_ctrl->Bind(wxEVT_TEXT_ENTER, &SpinInput::onTextEnter, this);
text_ctrl->Bind(wxEVT_KEY_DOWN, &SpinInput::keyPressed, this);