Add keyboard events support in ScrollBar
Pressing up/down/left/right keys makes the ScrollBar move Signed-off-by: Daker Fernandes Pinheiro <dakerfp@gmail.com>
This commit is contained in:
parent
aada03fb18
commit
decf76214c
@ -48,6 +48,47 @@ Item {
|
|||||||
|
|
||||||
visible: flickableItem && handle.width < contents.width
|
visible: flickableItem && handle.width < contents.width
|
||||||
|
|
||||||
|
Keys.onUpPressed: {
|
||||||
|
if (!_isVertical)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_inverted)
|
||||||
|
range.value -= stepSize;
|
||||||
|
else
|
||||||
|
range.value += stepSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onDownPressed: {
|
||||||
|
if (!_isVertical)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_inverted)
|
||||||
|
range.value += stepSize;
|
||||||
|
else
|
||||||
|
range.value -= stepSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onLeftPressed: {
|
||||||
|
if (_isVertical)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_inverted)
|
||||||
|
range.value += stepSize;
|
||||||
|
else
|
||||||
|
range.value -= stepSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onRightPressed: {
|
||||||
|
if (_isVertical)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_inverted)
|
||||||
|
range.value -= stepSize;
|
||||||
|
else
|
||||||
|
range.value += stepSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
||||||
width: _isVertical ? scrollbar.height : scrollbar.width
|
width: _isVertical ? scrollbar.height : scrollbar.width
|
||||||
@ -90,6 +131,7 @@ Item {
|
|||||||
running: parent.pressed
|
running: parent.pressed
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
|
scrollbar.forceActiveFocus();
|
||||||
if (_inverted)
|
if (_inverted)
|
||||||
_value += stepSize;
|
_value += stepSize;
|
||||||
else
|
else
|
||||||
@ -129,6 +171,7 @@ Item {
|
|||||||
running: parent.pressed;
|
running: parent.pressed;
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
|
scrollbar.forceActiveFocus();
|
||||||
if (_inverted)
|
if (_inverted)
|
||||||
_value -= stepSize
|
_value -= stepSize
|
||||||
else
|
else
|
||||||
|
@ -31,6 +31,7 @@ Rectangle {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
contentWidth: 2200
|
contentWidth: 2200
|
||||||
contentHeight: 600
|
contentHeight: 600
|
||||||
|
contentX: 500
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
x: 30
|
x: 30
|
||||||
@ -168,6 +169,7 @@ Rectangle {
|
|||||||
PlasmaComponents.BusyIndicator {
|
PlasmaComponents.BusyIndicator {
|
||||||
id: busy
|
id: busy
|
||||||
running: mouse.pressed
|
running: mouse.pressed
|
||||||
|
smoothAnimation: true
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouse
|
id: mouse
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@ -318,6 +320,8 @@ Rectangle {
|
|||||||
PlasmaComponents.ScrollBar {
|
PlasmaComponents.ScrollBar {
|
||||||
id: verticalScrollBar
|
id: verticalScrollBar
|
||||||
|
|
||||||
|
stepSize: 30
|
||||||
|
|
||||||
orientation: Qt.Vertical
|
orientation: Qt.Vertical
|
||||||
flickableItem: page
|
flickableItem: page
|
||||||
animated: true
|
animated: true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user