From c40de7e4240c448fa83bf76bcf4ed89700692c1c Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 5 Apr 2017 15:55:02 +0200 Subject: [PATCH] Fix of https://github.com/prusa3d/Slic3r/issues/218 Cut function bug in accepting a numerical value --- lib/Slic3r/GUI/OptionsGroup/Field.pm | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/Slic3r/GUI/OptionsGroup/Field.pm b/lib/Slic3r/GUI/OptionsGroup/Field.pm index bd3092f7c..4d64a64ee 100644 --- a/lib/Slic3r/GUI/OptionsGroup/Field.pm +++ b/lib/Slic3r/GUI/OptionsGroup/Field.pm @@ -547,13 +547,17 @@ sub BUILD { $sizer->Add($textctrl, 0, wxALIGN_CENTER_VERTICAL, 0); EVT_SLIDER($self->parent, $slider, sub { - $self->_update_textctrl; - $self->_on_change($self->option->opt_id); + if (! $self->disable_change_event) { + $self->textctrl->SetLabel($self->get_value); + $self->_on_change($self->option->opt_id); + } }); EVT_TEXT($self->parent, $textctrl, sub { my $value = $textctrl->GetValue; if ($value =~ /^-?\d+(\.\d*)?$/) { - $self->set_value($value); + $self->disable_change_event(1); + $self->slider->SetValue($value*$self->scale); + $self->disable_change_event(0); $self->_on_change($self->option->opt_id); } }); @@ -567,7 +571,7 @@ sub set_value { $self->disable_change_event(1); $self->slider->SetValue($value*$self->scale); - $self->_update_textctrl; + $self->textctrl->SetLabel($self->get_value); $self->disable_change_event(0); } @@ -576,11 +580,6 @@ sub get_value { return $self->slider->GetValue/$self->scale; } -sub _update_textctrl { - my ($self) = @_; - $self->textctrl->SetLabel($self->get_value); -} - sub enable { my ($self) = @_;