FIX: add cursor and enter processing for plate name

github:https://github.com/bambulab/BambuStudio/issues/2262#event-10081065971
jira:https://jira.bambooolab.com/browse/STUDIO-3992

Change-Id: Ie6120a8ff99f9568f9e42800429a1c5b378fc28f
(cherry picked from commit dbfc17943fa912470f26de1615088c87bd022b4e)
This commit is contained in:
zhou.xu 2023-08-14 09:50:35 +08:00 committed by Lane.Wei
parent cb38b71825
commit 780d9a7e93

View File

@ -224,6 +224,12 @@ PlateNameEditDialog::PlateNameEditDialog(wxWindow *parent, wxWindowID id, const
auto plate_name_txt = new wxStaticText(this, wxID_ANY, _L("Plate name"));
plate_name_txt->SetFont(Label::Body_14);
m_ti_plate_name = new TextInput(this, wxString::FromDouble(0.0), "", "", wxDefaultPosition, wxSize(FromDIP(240), -1), wxTE_PROCESS_ENTER);
m_ti_plate_name->Bind(wxEVT_TEXT_ENTER, [this](wxCommandEvent &e) {
if (this->IsModal())
EndModal(wxID_YES);
else
this->Close();
});
top_sizer->Add(plate_name_txt, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, FromDIP(5));
top_sizer->Add(m_ti_plate_name, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, FromDIP(5));
m_ti_plate_name->GetTextCtrl()->SetMaxLength(250);
@ -293,6 +299,10 @@ void PlateNameEditDialog::on_dpi_changed(const wxRect &suggested_rect)
wxString PlateNameEditDialog::get_plate_name() const { return m_ti_plate_name->GetTextCtrl()->GetValue(); }
void PlateNameEditDialog::set_plate_name(const wxString &name) { m_ti_plate_name->GetTextCtrl()->SetValue(name); }
void PlateNameEditDialog::set_plate_name(const wxString &name) {
m_ti_plate_name->GetTextCtrl()->SetValue(name);
m_ti_plate_name->GetTextCtrl()->SetFocus();
m_ti_plate_name->GetTextCtrl()->SetInsertionPointEnd();
}
}} // namespace Slic3r::GUI