Add keyboard events handling in Slider

Using the arrow keys enables the user to increase/decrease stepSize units
from the Slider's value.

Signed-off-by: Daker Fernandes Pinheiro <dakerfp@gmail.com>
This commit is contained in:
Daker Fernandes Pinheiro 2011-07-08 13:18:58 -03:00
parent decf76214c
commit 5ac7ececa9

View File

@ -20,7 +20,6 @@
import QtQuick 1.0
import org.kde.plasma.core 0.1 as PlasmaCore
// TODO: add support mouse wheel and key events
// TODO: create a value indicator for plasma?
Item {
id: slider
@ -46,6 +45,46 @@ Item {
width: _isVertical ? 22 : 200
height: _isVertical ? 200 : 22
Keys.onUpPressed: {
if (!_isVertical)
return;
if (inverted)
value -= stepSize;
else
value += stepSize;
}
Keys.onDownPressed: {
if (!_isVertical)
return;
if (inverted)
value += stepSize;
else
value -= stepSize;
}
Keys.onLeftPressed: {
if (_isVertical)
return;
if (inverted)
value += stepSize;
else
value -= stepSize;
}
Keys.onRightPressed: {
if (_isVertical)
return;
if (inverted)
value -= stepSize;
else
value += stepSize;
}
Item {
id: contents