From dabcff1c0747c04f1d1e9e33ef7258882221bb39 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 6 Jun 2017 19:14:52 +0200 Subject: [PATCH] When testing for a key press, rather check for the modifier keys (alt, ctrl) always. Also if a key event is not processed, pass it for further processing. --- lib/Slic3r/GUI/Plater/2DToolpaths.pm | 30 +++++++++++++++----------- lib/Slic3r/GUI/Plater/3DPreview.pm | 32 +++++++++++++++++----------- lib/Slic3r/GUI/Plater/3DToolpaths.pm | 21 +++++++++++------- 3 files changed, 50 insertions(+), 33 deletions(-) diff --git a/lib/Slic3r/GUI/Plater/2DToolpaths.pm b/lib/Slic3r/GUI/Plater/2DToolpaths.pm index 0a4399490..c80c410ef 100644 --- a/lib/Slic3r/GUI/Plater/2DToolpaths.pm +++ b/lib/Slic3r/GUI/Plater/2DToolpaths.pm @@ -52,18 +52,24 @@ sub new { }); EVT_KEY_DOWN($canvas, sub { my ($s, $event) = @_; - my $key = $event->GetKeyCode; - if ($key == ord('D') || $key == WXK_LEFT) { - # Keys: 'D' or WXK_LEFT - $slider->SetValue($slider->GetValue - 1); - $self->set_z($self->{layers_z}[$slider->GetValue]); - } elsif ($key == ord('U') || $key == WXK_RIGHT) { - # Keys: 'U' or WXK_RIGHT - $slider->SetValue($slider->GetValue + 1); - $self->set_z($self->{layers_z}[$slider->GetValue]); - } elsif ($key >= ord('1') && $key <= ord('3')) { - # Keys: '1' to '3' - $canvas->set_simulation_mode($key - ord('1')); + if ($event->HasModifiers) { + $event->Skip; + } else { + my $key = $event->GetKeyCode; + if ($key == ord('D') || $key == WXK_LEFT) { + # Keys: 'D' or WXK_LEFT + $slider->SetValue($slider->GetValue - 1); + $self->set_z($self->{layers_z}[$slider->GetValue]); + } elsif ($key == ord('U') || $key == WXK_RIGHT) { + # Keys: 'U' or WXK_RIGHT + $slider->SetValue($slider->GetValue + 1); + $self->set_z($self->{layers_z}[$slider->GetValue]); + } elsif ($key >= ord('1') && $key <= ord('3')) { + # Keys: '1' to '3' + $canvas->set_simulation_mode($key - ord('1')); + } else { + $event->Skip; + } } }); diff --git a/lib/Slic3r/GUI/Plater/3DPreview.pm b/lib/Slic3r/GUI/Plater/3DPreview.pm index 305f865e4..5663054f1 100644 --- a/lib/Slic3r/GUI/Plater/3DPreview.pm +++ b/lib/Slic3r/GUI/Plater/3DPreview.pm @@ -89,20 +89,26 @@ sub new { EVT_KEY_DOWN($canvas, sub { my ($s, $event) = @_; my $key = $event->GetKeyCode; - if ($key == ord('U') || $key == WXK_RIGHT) { - $slider_high->SetValue($slider_high->GetValue + 1); - $slider_low->SetValue($slider_high->GetValue) if ($event->ShiftDown()); - $self->set_z_idx_high($slider_high->GetValue); - } elsif ($key == ord('D') || $key == WXK_LEFT) { - $slider_high->SetValue($slider_high->GetValue - 1); - $slider_low->SetValue($slider_high->GetValue) if ($event->ShiftDown()); - $self->set_z_idx_high($slider_high->GetValue); - } elsif ($key == ord('S')) { - $checkbox_singlelayer->SetValue(! $checkbox_singlelayer->GetValue()); - $self->single_layer($checkbox_singlelayer->GetValue()); - if ($self->single_layer) { - $slider_low->SetValue($slider_high->GetValue); + if ($event->HasModifiers) { + $event->Skip; + } else { + if ($key == ord('U') || $key == WXK_RIGHT) { + $slider_high->SetValue($slider_high->GetValue + 1); + $slider_low->SetValue($slider_high->GetValue) if ($event->ShiftDown()); $self->set_z_idx_high($slider_high->GetValue); + } elsif ($key == ord('D') || $key == WXK_LEFT) { + $slider_high->SetValue($slider_high->GetValue - 1); + $slider_low->SetValue($slider_high->GetValue) if ($event->ShiftDown()); + $self->set_z_idx_high($slider_high->GetValue); + } elsif ($key == ord('S')) { + $checkbox_singlelayer->SetValue(! $checkbox_singlelayer->GetValue()); + $self->single_layer($checkbox_singlelayer->GetValue()); + if ($self->single_layer) { + $slider_low->SetValue($slider_high->GetValue); + $self->set_z_idx_high($slider_high->GetValue); + } + } else { + $event->Skip; } } }); diff --git a/lib/Slic3r/GUI/Plater/3DToolpaths.pm b/lib/Slic3r/GUI/Plater/3DToolpaths.pm index 0575daa84..fb904b0fd 100644 --- a/lib/Slic3r/GUI/Plater/3DToolpaths.pm +++ b/lib/Slic3r/GUI/Plater/3DToolpaths.pm @@ -50,14 +50,19 @@ sub new { }); EVT_KEY_DOWN($canvas, sub { my ($s, $event) = @_; - - my $key = $event->GetKeyCode; - if ($key == 85 || $key == 315) { - $slider->SetValue($slider->GetValue + 1); - $self->set_z($self->{layers_z}[$slider->GetValue]); - } elsif ($key == 68 || $key == 317) { - $slider->SetValue($slider->GetValue - 1); - $self->set_z($self->{layers_z}[$slider->GetValue]); + if ($event->HasModifiers) { + $event->Skip; + } else { + my $key = $event->GetKeyCode; + if ($key == 85 || $key == 315) { + $slider->SetValue($slider->GetValue + 1); + $self->set_z($self->{layers_z}[$slider->GetValue]); + } elsif ($key == 68 || $key == 317) { + $slider->SetValue($slider->GetValue - 1); + $self->set_z($self->{layers_z}[$slider->GetValue]); + } else { + $event->Skip; + } } });