* 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:
@@ -70,6 +70,7 @@ public:
|
|||||||
virtual void FrameMoved(BPoint newPosition);
|
virtual void FrameMoved(BPoint newPosition);
|
||||||
virtual void FrameResized(float width, float height);
|
virtual void FrameResized(float width, float height);
|
||||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
|
virtual void KeyUp(const char* bytes, int32 numBytes);
|
||||||
virtual void MouseDown(BPoint point);
|
virtual void MouseDown(BPoint point);
|
||||||
virtual void MouseUp(BPoint point);
|
virtual void MouseUp(BPoint point);
|
||||||
virtual void MouseMoved(BPoint point, uint32 transit,
|
virtual void MouseMoved(BPoint point, uint32 transit,
|
||||||
@@ -80,7 +81,7 @@ public:
|
|||||||
virtual void SetLimitLabels(const char* minLabel,
|
virtual void SetLimitLabels(const char* minLabel,
|
||||||
const char* maxLabel);
|
const char* maxLabel);
|
||||||
const char* MinLimitLabel() const;
|
const char* MinLimitLabel() const;
|
||||||
const char* MaxLimitLabel() const;
|
const char* MaxLimitLabel() const;
|
||||||
virtual void SetValue(int32);
|
virtual void SetValue(int32);
|
||||||
virtual int32 ValueForPoint(BPoint) const;
|
virtual int32 ValueForPoint(BPoint) const;
|
||||||
virtual void SetPosition(float);
|
virtual void SetPosition(float);
|
||||||
|
|||||||
@@ -481,32 +481,52 @@ BSlider::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
|
|
||||||
switch (bytes[0]) {
|
switch (bytes[0]) {
|
||||||
case B_LEFT_ARROW:
|
case B_LEFT_ARROW:
|
||||||
case B_DOWN_ARROW: {
|
case B_DOWN_ARROW:
|
||||||
newValue -= KeyIncrementValue();
|
newValue -= KeyIncrementValue();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case B_RIGHT_ARROW:
|
case B_RIGHT_ARROW:
|
||||||
case B_UP_ARROW: {
|
case B_UP_ARROW:
|
||||||
newValue += KeyIncrementValue();
|
newValue += KeyIncrementValue();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case B_HOME:
|
case B_HOME:
|
||||||
newValue = fMinValue;
|
newValue = fMinValue;
|
||||||
break;
|
break;
|
||||||
case B_END:
|
case B_END:
|
||||||
newValue = fMaxValue;
|
newValue = fMaxValue;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BControl::KeyDown(bytes, numBytes);
|
BControl::KeyDown(bytes, numBytes);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newValue < fMinValue)
|
||||||
|
newValue = fMinValue;
|
||||||
|
if (newValue > fMaxValue)
|
||||||
|
newValue = fMaxValue;
|
||||||
|
|
||||||
if (newValue != Value()) {
|
if (newValue != Value()) {
|
||||||
|
fInitialLocation = _Location();
|
||||||
SetValue(newValue);
|
SetValue(newValue);
|
||||||
InvokeNotify(ModificationMessage(), B_CONTROL_MODIFIED);
|
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.
|
Makes sure the \a point is within valid bounds.
|
||||||
@@ -673,7 +693,7 @@ BSlider::SetValue(int32 value)
|
|||||||
|
|
||||||
if (value == Value())
|
if (value == Value())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_SetLocationForValue(value);
|
_SetLocationForValue(value);
|
||||||
|
|
||||||
BRect oldThumbFrame = ThumbFrame();
|
BRect oldThumbFrame = ThumbFrame();
|
||||||
|
|||||||
Reference in New Issue
Block a user