Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuSanka <yusanka@gmail.com>2018-12-11 15:34:37 +0300
committerYuSanka <yusanka@gmail.com>2018-12-11 16:05:56 +0300
commitd7bc1410eea26c7b44f4657964a57b50d64894e5 (patch)
tree8a6ef6797670a728058fa4e594a8ff320e1a1b2a /src/slic3r/GUI/Field.cpp
parentc4e334f8633d93ef9752cad53c5ea0dc936ccaee (diff)
Update value inside TextCtrl & SpinCtrl after wxEVT_KILL_FOCES instead of wxEVT_TEXT (or wxEVT_TEXT_ENTER)
Diffstat (limited to 'src/slic3r/GUI/Field.cpp')
-rw-r--r--src/slic3r/GUI/Field.cpp40
1 files changed, 22 insertions, 18 deletions
diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp
index 14f409698..29218eaf6 100644
--- a/src/slic3r/GUI/Field.cpp
+++ b/src/slic3r/GUI/Field.cpp
@@ -74,7 +74,7 @@ void Field::on_kill_focus(wxEvent& event)
event.Skip();
// call the registered function if it is available
if (m_on_kill_focus!=nullptr)
- m_on_kill_focus();
+ m_on_kill_focus(m_opt_id);
}
void Field::on_change_field()
@@ -125,9 +125,9 @@ void Field::get_value_by_opt_type(wxString& str)
case coPercents:
case coFloats:
case coFloat:{
- if (m_opt.type == coPercent && str.Last() == '%')
+ if (m_opt.type == coPercent && !str.IsEmpty() && str.Last() == '%')
str.RemoveLast();
- else if (str.Last() == '%') {
+ else if (!str.IsEmpty() && str.Last() == '%') {
wxString label = m_Label->GetLabel();
if (label.Last() == '\n') label.RemoveLast();
while (label.Last() == ' ') label.RemoveLast();
@@ -162,7 +162,7 @@ void Field::get_value_by_opt_type(wxString& str)
}
}
-bool TextCtrl::is_defined_input_value()
+bool TextCtrl::is_defined_input_value() const
{
if (static_cast<wxTextCtrl*>(window)->GetValue().empty() && m_opt.type != coString && m_opt.type != coStrings)
return false;
@@ -216,7 +216,7 @@ void TextCtrl::BUILD() {
break;
}
- const long style = m_opt.multiline ? wxTE_MULTILINE : 0 | m_process_enter ? wxTE_PROCESS_ENTER : 0;
+ const long style = m_opt.multiline ? wxTE_MULTILINE : 0;
auto temp = new wxTextCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size, style);
temp->SetToolTip(get_tooltip_text(text_value));
@@ -240,17 +240,13 @@ void TextCtrl::BUILD() {
e.Skip();
temp->GetToolTip()->Enable(true);
#endif // __WXGTK__
- if (!is_defined_input_value())
+// if (!is_defined_input_value())
+ if (is_defined_input_value())
+ on_change_field();
+ else
on_kill_focus(e);
}), temp->GetId());
-
- if (m_process_enter) {
- temp->Bind(wxEVT_TEXT_ENTER, ([this](wxCommandEvent& evt) {
- if(is_defined_input_value())
- on_change_field();
- }), temp->GetId());
- }
- else {
+ /*
temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent& evt)
{
#ifdef __WXGTK__
@@ -267,8 +263,7 @@ void TextCtrl::BUILD() {
temp->Bind(wxEVT_KEY_DOWN, &TextCtrl::change_field_value, this);
temp->Bind(wxEVT_KEY_UP, &TextCtrl::change_field_value, this);
#endif //__WXGTK__
- }
-
+*/
// select all text using Ctrl+A
temp->Bind(wxEVT_CHAR, ([temp](wxKeyEvent& event)
{
@@ -371,7 +366,15 @@ void SpinCtrl::BUILD() {
0, min_val, max_val, default_value);
// temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { tmp_value = undef_spin_val; on_change_field(); }), temp->GetId());
- temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { on_kill_focus(e); }), temp->GetId());
+ temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e)
+ {
+ if (tmp_value < 0)
+ on_kill_focus(e);
+ else {
+ e.Skip();
+ on_change_field();
+ }
+ }), temp->GetId());
temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e)
{
// # On OSX / Cocoa, wxSpinCtrl::GetValue() doesn't return the new value
@@ -382,7 +385,8 @@ void SpinCtrl::BUILD() {
std::string value = e.GetString().utf8_str().data();
if (is_matched(value, "^\\d+$"))
tmp_value = std::stoi(value);
- on_change_field();
+ else tmp_value = -9999;
+// on_change_field();
// # We don't reset tmp_value here because _on_change might put callbacks
// # in the CallAfter queue, and we want the tmp value to be available from
// # them as well.