You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -245,20 +241,20 @@ open class Aether(renderer: UIRenderer) {
245
241
* as de-focusing the focused component and adding listeners to input.
246
242
*/
247
243
companionobject Properties {
248
-
249
-
val timings:Timings=Timings()
250
-
251
244
@JvmStatic
252
245
var debug:Boolean=true
253
246
254
247
@JvmStatic
255
248
lateinitvar instance:Aether
249
+
protected set
256
250
257
251
@JvmStatic
258
252
lateinitvar renderer:UIRenderer
253
+
protected set
259
254
260
255
@JvmStatic
261
256
var activeScreen:UIScreen?=null
257
+
protected set
262
258
263
259
/**
264
260
* The focused component (if applicable).
@@ -269,79 +265,92 @@ open class Aether(renderer: UIRenderer) {
269
265
*/
270
266
@JvmStatic
271
267
var focusedComponent:UIFocusable?=null
268
+
protected set
272
269
273
270
/**
274
271
* The width of the screen. It can be set via [update]
275
272
*/
276
273
@JvmStatic
277
274
var width:Float=0f
275
+
protected set
278
276
279
277
/**
280
278
* The width of the screen. It can be set via [update]
281
279
*/
282
280
@JvmStatic
283
281
var height:Float=0f
282
+
protected set
284
283
285
284
/**
286
285
* The device pixel ratio. It can be set via [update]. It is the equivalent of content scale.
287
286
*/
288
287
@JvmStatic
289
288
var devicePxRatio:Float=1f
289
+
protected set
290
290
291
291
/**
292
292
* The x position of the mouse relative to the screen
293
293
*/
294
294
@JvmStatic
295
295
var mouseX:Float=0f
296
+
protected set
296
297
297
298
/**
298
299
* The y position of the mouse relative to the screen
299
300
*/
300
301
@JvmStatic
301
302
var mouseY:Float=0f
303
+
protected set
302
304
303
305
/**
304
306
* Invoked whenever the layout needs to be updated. This can be when the screen
305
307
* is resized or created. Invoked prior to components.
306
308
*/
307
309
@JvmStatic
308
310
var updateListeners:HashMap<String, Runnable>?=null
311
+
protected set
309
312
310
313
/**
311
314
* The listeners for then the mouse is moved. Invoked prior to components.
312
315
*/
313
316
@JvmStatic
314
317
var mouseMoveListeners:HashMap<String, Runnable>?=null
318
+
protected set
315
319
316
320
/**
317
321
* Invoked when the mouse is pressed. Invoked prior to components.
318
322
*/
319
323
@JvmStatic
320
324
var mousePressedListeners:HashMap<String, Runnable>?=null
325
+
protected set
321
326
322
327
/**
323
328
* Invoked when the mouse is released. Invoked prior to components.
324
329
*/
325
330
@JvmStatic
326
331
var mouseReleasedListeners:HashMap<String, Runnable>?=null
332
+
protected set
327
333
328
334
/**
329
335
* Invoked when a key is pressed. Invoked prior to components.
330
336
*/
331
337
@JvmStatic
332
338
var keyPressListeners:HashMap<String, Consumer<Char>>?=null
339
+
protected set
333
340
334
341
/**
335
342
* Invoked when the mouse is scrolled. Invoked prior to components.
336
343
*/
337
344
@JvmStatic
338
345
var mouseScrollListeners:HashMap<String, Consumer<Float>>?=null
346
+
protected set
339
347
340
348
/**
341
349
* Invoked when the screen is deleted. This is used to deallocate listeners added to UICore.
342
350
*/
343
351
@JvmStatic
344
352
var deallocationListeners:HashMap<String, Runnable>?=null
353
+
protected set
345
354
346
355
/**
347
356
* The list of modifier keys. The value is if the key is pressed
@@ -493,7 +502,13 @@ open class Aether(renderer: UIRenderer) {
493
502
* Focuses the component. Please use [UIComponent.focus] instead.
494
503
*/
495
504
@JvmStatic
496
-
fun <T> focus(component:T) where T : UIComponent<*>, T : UIFocusable {
505
+
funfocus(component:UIFocusable) {
506
+
// Check if the given value is a valid instance of UIComponent
507
+
try {
508
+
component asUIComponent<*>
509
+
} catch (castException:ClassCastException) {
510
+
throwRuntimeException("When trying to focus, the provided value is not an instance of UIComponent. Make sure you are only using the UIFocus interface to focus UIComponents.")
511
+
}
497
512
focusedComponent = component
498
513
}
499
514
@@ -533,7 +548,7 @@ open class Aether(renderer: UIRenderer) {
533
548
for (i in0 until instance.frames!!.size) {
534
549
// UIContainers are what control scrolling, so
535
550
// if it is not an instance of it, skip and continue
536
-
val container = instance.frames!![i] as?UIContainer<UIContainerSheet> ?:continue
551
+
val container = instance.frames!![i] as?UIContainer<*> ?:continue
537
552
if (container.isMouseInsideBounds() && container.expandedHeight >0f&& container.style.overflowY !=UIContainerSheet.Overflow.None) {
538
553
// Iterate through the frame to see if there are more
539
554
// containers with it. If there are, it will pass true
0 commit comments