@@ -59,6 +59,7 @@ public TestSceneSliderBar()
59
59
Size = new Vector2 ( 200 , 50 ) ,
60
60
BackgroundColour = Color4 . White ,
61
61
SelectionColour = Color4 . Pink ,
62
+ FocusColour = Color4 . OrangeRed ,
62
63
KeyboardStep = 1 ,
63
64
Current = sliderBarValue
64
65
} ,
@@ -72,6 +73,7 @@ public TestSceneSliderBar()
72
73
RangePadding = 20 ,
73
74
BackgroundColour = Color4 . White ,
74
75
SelectionColour = Color4 . Pink ,
76
+ FocusColour = Color4 . OrangeRed ,
75
77
KeyboardStep = 1 ,
76
78
Current = sliderBarValue
77
79
} ,
@@ -85,6 +87,7 @@ public TestSceneSliderBar()
85
87
Size = new Vector2 ( 200 , 10 ) ,
86
88
BackgroundColour = Color4 . White ,
87
89
SelectionColour = Color4 . Pink ,
90
+ FocusColour = Color4 . OrangeRed ,
88
91
KeyboardStep = 1 ,
89
92
Current = sliderBarValue
90
93
} ,
@@ -97,6 +100,7 @@ public TestSceneSliderBar()
97
100
Size = new Vector2 ( 200 , 10 ) ,
98
101
BackgroundColour = Color4 . White ,
99
102
SelectionColour = Color4 . Pink ,
103
+ FocusColour = Color4 . OrangeRed ,
100
104
KeyboardStep = 1 ,
101
105
Current = sliderBarValue
102
106
} ,
@@ -109,6 +113,8 @@ public TestSceneSliderBar()
109
113
{
110
114
sliderBar . Current . Disabled = false ;
111
115
sliderBar . Current . Value = 0 ;
116
+ sliderBar . GetContainingFocusManager ( ) ! . ChangeFocus ( null ) ;
117
+ sliderBarWithNub . GetContainingFocusManager ( ) ! . ChangeFocus ( null ) ;
112
118
} ) ;
113
119
114
120
[ Test ]
@@ -122,6 +128,7 @@ public void TestVerticalDragHasNoEffect()
122
128
( ) => { InputManager . MoveMouseTo ( sliderBar . ToScreenSpace ( sliderBar . DrawSize * new Vector2 ( 0.75f , 1f ) ) ) ; } ) ;
123
129
AddStep ( "Release Click" , ( ) => { InputManager . ReleaseButton ( MouseButton . Left ) ; } ) ;
124
130
checkValue ( 0 ) ;
131
+ AddAssert ( "Slider has no focus" , ( ) => ! sliderBar . HasFocus ) ;
125
132
}
126
133
127
134
[ Test ]
@@ -136,6 +143,7 @@ public void TestDragOutReleaseInHasNoEffect()
136
143
AddStep ( "Drag Up" , ( ) => { InputManager . MoveMouseTo ( sliderBar . ToScreenSpace ( sliderBar . DrawSize * new Vector2 ( 0.25f , 0.5f ) ) ) ; } ) ;
137
144
AddStep ( "Release Click" , ( ) => { InputManager . ReleaseButton ( MouseButton . Left ) ; } ) ;
138
145
checkValue ( 0 ) ;
146
+ AddAssert ( "Slider has focus" , ( ) => sliderBar . HasFocus ) ;
139
147
}
140
148
141
149
[ Test ]
@@ -160,6 +168,23 @@ public void TestKeyboardInput()
160
168
InputManager . ReleaseKey ( Key . Right ) ;
161
169
} ) ;
162
170
checkValue ( 1 ) ;
171
+
172
+ AddStep ( "Click slider" , ( ) => InputManager . Click ( MouseButton . Left ) ) ;
173
+ checkValue ( - 5 ) ;
174
+
175
+ AddAssert ( "Slider has focus" , ( ) => sliderBar . HasFocus ) ;
176
+
177
+ AddStep ( "move mouse outside" , ( ) =>
178
+ {
179
+ InputManager . MoveMouseTo ( sliderBar . ToScreenSpace ( sliderBar . DrawSize * new Vector2 ( 2f , 0.5f ) ) ) ;
180
+ } ) ;
181
+
182
+ AddStep ( "Press right arrow key" , ( ) =>
183
+ {
184
+ InputManager . PressKey ( Key . Right ) ;
185
+ InputManager . ReleaseKey ( Key . Right ) ;
186
+ } ) ;
187
+ checkValue ( - 4 ) ;
163
188
}
164
189
165
190
[ TestCase ( false ) ]
@@ -246,6 +271,7 @@ public void TestAbsoluteDrag()
246
271
( ) => { InputManager . MoveMouseTo ( sliderBarWithNub . ToScreenSpace ( sliderBarWithNub . DrawSize * new Vector2 ( 0.4f , 1f ) ) ) ; } ) ;
247
272
AddStep ( "Release Click" , ( ) => { InputManager . ReleaseButton ( MouseButton . Left ) ; } ) ;
248
273
checkValue ( - 2 ) ;
274
+ AddAssert ( "Slider has focus" , ( ) => sliderBarWithNub . HasFocus ) ;
249
275
}
250
276
251
277
[ Test ]
@@ -259,6 +285,7 @@ public void TestRelativeDrag()
259
285
( ) => { InputManager . MoveMouseTo ( sliderBarWithNub . ToScreenSpace ( sliderBarWithNub . DrawSize * new Vector2 ( 0.75f , 1f ) ) ) ; } ) ;
260
286
AddStep ( "Release Click" , ( ) => { InputManager . ReleaseButton ( MouseButton . Left ) ; } ) ;
261
287
checkValue ( 3 ) ;
288
+ AddAssert ( "Slider has focus" , ( ) => sliderBarWithNub . HasFocus ) ;
262
289
}
263
290
264
291
[ Test ]
0 commit comments