Skip to content

Commit 3969688

Browse files
committed
Modified the behavior of spinner widget to make 5x steps, 10x steps
increments with key combination ctrl+ up/down(5x); ctrl + page up/page down(10x); ctrl + left/right (10x)
1 parent 22b3713 commit 3969688

File tree

2 files changed

+30
-23
lines changed

2 files changed

+30
-23
lines changed

app/display/model/src/main/resources/examples/controls_spinner_slider_scrollbar.bob

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<display version="1.0.0">
2+
<display version="2.0.0">
33
<name>Spinner Slider Scrollbar</name>
44
<widget type="scrollbar" version="2.0.0">
55
<name>Scrollbar</name>
@@ -45,7 +45,6 @@
4545
<width>110</width>
4646
<height>220</height>
4747
<horizontal>false</horizontal>
48-
<scale_format>#.##</scale_format>
4948
</widget>
5049
<widget type="label" version="2.0.0">
5150
<name>Label_3</name>
@@ -70,18 +69,17 @@
7069
</widget>
7170
<widget type="label" version="2.0.0">
7271
<name>Label_5</name>
73-
<text>The value can be adjusted both with
74-
the mouse and, when the widget is in
75-
focus, using the arrow keys and
76-
page up/down keys.
72+
<text>The value can be adjusted both with the mouse and, when the widget is in focus, using the arrow keys and page up/down keys.
73+
Up/Down arrow keys and Page Up/Down keys will change the value by 1 step size
74+
Ctrl + Up/Down arrow keys will change the value by 5 x step size
75+
Ctrl + Page Up/Down keys will change the value by 10 x step size
76+
To make it up for some keyboard that need Fn keys to activate Page Up/Down, one can also use Ctrl Left/Right arrow keys to make changes at 10 x step szie
7777

78-
The "increment" property of the widget
79-
determines the step size when using
80-
the keyboard.</text>
81-
<x>143</x>
82-
<y>191</y>
83-
<width>238</width>
84-
<height>189</height>
78+
The "increment" property of the widget determines the step size when using the keyboard.</text>
79+
<x>141</x>
80+
<y>160</y>
81+
<width>579</width>
82+
<height>250</height>
8583
</widget>
8684
<widget type="scaledslider" version="2.0.0">
8785
<name>Scaled Slider_1</name>
@@ -90,7 +88,6 @@ the keyboard.</text>
9088
<y>429</y>
9189
<width>419</width>
9290
<height>61</height>
93-
<scale_format>#.##</scale_format>
9491
<limits_from_pv>false</limits_from_pv>
9592
</widget>
9693
</display>

app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/SpinnerRepresentation.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,19 @@ else if(focused){
106106
break;
107107
//incrementing by keyboard
108108
//isShiftDown(), isControlDown(), isAltDown(), and isMetaDown()
109+
case LEFT:
110+
if(event.isControlDown()) {
111+
spinner.getValueFactory().increment(10);
112+
}
113+
break;
114+
case RIGHT:
115+
if(event.isControlDown()) {
116+
spinner.getValueFactory().decrement(10);
117+
}
118+
break;
109119
case UP:
110120
if (!active) {
111-
if(event.isAltDown()) {
121+
if(event.isControlDown()) {
112122
spinner.getValueFactory().increment(5);
113123
}
114124
else {
@@ -118,17 +128,17 @@ else if(focused){
118128
break;
119129
case PAGE_UP:
120130
if (!active) {
121-
if(event.isAltDown()) {
122-
spinner.getValueFactory().increment(50);
131+
if(event.isControlDown()) {
132+
spinner.getValueFactory().increment(10);
123133
}
124134
else {
125-
spinner.getValueFactory().increment(10);
135+
spinner.getValueFactory().increment(1);
126136
}
127137
}
128138
break;
129139
case DOWN:
130140
if (!active) {
131-
if(event.isAltDown()) {
141+
if(event.isControlDown()) {
132142
spinner.getValueFactory().decrement(5);
133143
}
134144
else {
@@ -138,15 +148,15 @@ else if(focused){
138148
break;
139149
case PAGE_DOWN:
140150
if (!active) {
141-
if(event.isAltDown()) {
142-
spinner.getValueFactory().decrement(50);
151+
if(event.isControlDown()) {
152+
spinner.getValueFactory().decrement(10);
143153
}
144154
else {
145-
spinner.getValueFactory().decrement(10);
155+
spinner.getValueFactory().decrement(1);
146156
}
147157
}
148158
break;
149-
case ALT:
159+
case CONTROL:
150160
setActive(false);
151161
break;
152162
default:

0 commit comments

Comments
 (0)