From 01c2f44ee8cbe8d17179c6c4b172ea4196cc7420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 8 Jan 2008 16:39:00 +0000 Subject: [PATCH] * fix keyboard handling to trigger the correct invokation message * add support for B_HOME and B_END key (jump to min/max value) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23285 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Slider.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/kits/interface/Slider.cpp b/src/kits/interface/Slider.cpp index 5a3c7d5866..9e3b55b5a6 100644 --- a/src/kits/interface/Slider.cpp +++ b/src/kits/interface/Slider.cpp @@ -404,27 +404,33 @@ BSlider::KeyDown(const char *bytes, int32 numBytes) if (!IsEnabled() || IsHidden()) return; + int32 newValue = Value(); + switch (bytes[0]) { case B_LEFT_ARROW: case B_DOWN_ARROW: { - int32 oldValue = Value(); - - SetValue(Value() - KeyIncrementValue()); - if (oldValue != Value()) - Invoke(); + newValue -= KeyIncrementValue(); break; } case B_RIGHT_ARROW: case B_UP_ARROW: { - int32 oldValue = Value(); - - SetValue(Value() + KeyIncrementValue()); - if (oldValue != Value()) - Invoke(); + newValue += KeyIncrementValue(); break; } + case B_HOME: + newValue = fMinValue; + break; + case B_END: + newValue = fMaxValue; + break; default: BControl::KeyDown(bytes, numBytes); + return; + } + + if (newValue != Value()) { + SetValue(newValue); + InvokeNotify(ModificationMessage(), B_CONTROL_MODIFIED); } }