* Reuse the check for changed location which decides whether
to Invoke() in MouseUp() in the code path for keyboard control. Should fix ticket #6792, but I have not actually tested it. * Don't post notification values in KeyDown() when the value did not change because it was constrained between min and max values. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39323 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
328932ac9e
commit
e6cb8eb4c6
@ -70,6 +70,7 @@ public:
|
||||
virtual void FrameMoved(BPoint newPosition);
|
||||
virtual void FrameResized(float width, float height);
|
||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||
virtual void KeyUp(const char* bytes, int32 numBytes);
|
||||
virtual void MouseDown(BPoint point);
|
||||
virtual void MouseUp(BPoint point);
|
||||
virtual void MouseMoved(BPoint point, uint32 transit,
|
||||
@ -80,7 +81,7 @@ public:
|
||||
virtual void SetLimitLabels(const char* minLabel,
|
||||
const char* maxLabel);
|
||||
const char* MinLimitLabel() const;
|
||||
const char* MaxLimitLabel() const;
|
||||
const char* MaxLimitLabel() const;
|
||||
virtual void SetValue(int32);
|
||||
virtual int32 ValueForPoint(BPoint) const;
|
||||
virtual void SetPosition(float);
|
||||
|
@ -481,32 +481,52 @@ BSlider::KeyDown(const char *bytes, int32 numBytes)
|
||||
|
||||
switch (bytes[0]) {
|
||||
case B_LEFT_ARROW:
|
||||
case B_DOWN_ARROW: {
|
||||
case B_DOWN_ARROW:
|
||||
newValue -= KeyIncrementValue();
|
||||
break;
|
||||
}
|
||||
|
||||
case B_RIGHT_ARROW:
|
||||
case B_UP_ARROW: {
|
||||
case B_UP_ARROW:
|
||||
newValue += KeyIncrementValue();
|
||||
break;
|
||||
}
|
||||
|
||||
case B_HOME:
|
||||
newValue = fMinValue;
|
||||
break;
|
||||
case B_END:
|
||||
newValue = fMaxValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
BControl::KeyDown(bytes, numBytes);
|
||||
return;
|
||||
}
|
||||
|
||||
if (newValue < fMinValue)
|
||||
newValue = fMinValue;
|
||||
if (newValue > fMaxValue)
|
||||
newValue = fMaxValue;
|
||||
|
||||
if (newValue != Value()) {
|
||||
fInitialLocation = _Location();
|
||||
SetValue(newValue);
|
||||
InvokeNotify(ModificationMessage(), B_CONTROL_MODIFIED);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BSlider::KeyUp(const char *bytes, int32 numBytes)
|
||||
{
|
||||
if (fInitialLocation != _Location()) {
|
||||
// The last KeyDown event triggered the modification message or no
|
||||
// notification at all, we may also have sent the modification message
|
||||
// continually while the user kept pressing the key. In either case,
|
||||
// finish with the final message to make the behavior consistent with
|
||||
// changing the value by mouse.
|
||||
Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Makes sure the \a point is within valid bounds.
|
||||
@ -673,7 +693,7 @@ BSlider::SetValue(int32 value)
|
||||
|
||||
if (value == Value())
|
||||
return;
|
||||
|
||||
|
||||
_SetLocationForValue(value);
|
||||
|
||||
BRect oldThumbFrame = ThumbFrame();
|
||||
|
Loading…
Reference in New Issue
Block a user