@@ -351,7 +351,7 @@ private void NotifyAttaching(Base parent)
351351 ApplicationContext . Context . Value ? . Logger . LogWarning (
352352 exception ,
353353 "Error occurred while invoking OnAttaching() for {NodeName}" ,
354- CanonicalName
354+ ParentQualifiedName
355355 ) ;
356356 }
357357 }
@@ -375,7 +375,7 @@ private void NotifyDetaching(Base parent)
375375 ApplicationContext . Context . Value ? . Logger . LogWarning (
376376 exception ,
377377 "Error occurred while invoking OnDetaching() for {NodeName}" ,
378- CanonicalName
378+ ParentQualifiedName
379379 ) ;
380380 }
381381 }
@@ -397,7 +397,7 @@ private void NotifyDetachingFromRoot(Base root)
397397 ApplicationContext . Context . Value ? . Logger . LogWarning (
398398 exception ,
399399 "Error occurred while invoking OnDetachingFromRoot() for {NodeName}" ,
400- CanonicalName
400+ ParentQualifiedName
401401 ) ;
402402 }
403403
@@ -411,8 +411,8 @@ private void NotifyDetachingFromRoot(Base root)
411411 ApplicationContext . Context . Value ? . Logger . LogWarning (
412412 exception ,
413413 "Error occurred while invoking NotifyDetachingFromRoot() for {NodeName} from {RootName}" ,
414- CanonicalName ,
415- root . CanonicalName
414+ ParentQualifiedName ,
415+ root . ParentQualifiedName
416416 ) ;
417417 }
418418 }
@@ -434,7 +434,7 @@ private void NotifyAttachingToRoot(Base root)
434434 ApplicationContext . Context . Value ? . Logger . LogWarning (
435435 exception ,
436436 "Error occurred while invoking OnAttachingToRoot() for {NodeName}" ,
437- CanonicalName
437+ ParentQualifiedName
438438 ) ;
439439 }
440440
@@ -448,8 +448,8 @@ private void NotifyAttachingToRoot(Base root)
448448 ApplicationContext . Context . Value ? . Logger . LogWarning (
449449 exception ,
450450 "Error occurred while invoking NotifyAttachingToRoot() for {NodeName} to {RootName}" ,
451- CanonicalName ,
452- root . CanonicalName
451+ ParentQualifiedName ,
452+ root . ParentQualifiedName
453453 ) ;
454454 }
455455 }
@@ -471,8 +471,8 @@ private void PropagateCanvas(Canvas? canvas)
471471 ApplicationContext . Context . Value ? . Logger . LogWarning (
472472 exception ,
473473 "Exception thrown while invoking PropagateCanvas() for {NodeName} with {CanvasName}" ,
474- CanonicalName ,
475- canvas ? . CanonicalName ?? "null"
474+ ParentQualifiedName ,
475+ canvas ? . ParentQualifiedName ?? "null"
476476 ) ;
477477 }
478478 }
@@ -623,7 +623,7 @@ public virtual string? TooltipText
623623 {
624624 ApplicationContext . CurrentContext . Logger . LogWarning (
625625 "Unable to set tooltip text of {ControlName} to '{TooltipText}' because it is set to an incompatible control type {ControlType}" ,
626- CanonicalName ,
626+ ParentQualifiedName ,
627627 value ,
628628 _tooltip . GetType ( ) . GetName ( qualified : true )
629629 ) ;
@@ -895,14 +895,22 @@ public bool ShouldCacheToTexture
895895 /// <summary>
896896 /// Gets the control's internal canonical name.
897897 /// </summary>
898- public string CanonicalName => mParent == null ? Name : mParent . Name + "." + Name ;
898+ public string ParentQualifiedName =>
899+ mParent is { } parent ? $ "{ parent . Name } .{ Name } " : Name ;
900+
901+ public string CanonicalName =>
902+ ( mActualParent ?? mParent ) is { } parent
903+ ? $ "{ parent . CanonicalName } .{ Name } "
904+ : _name ?? $ "(unnamed { GetType ( ) . GetName ( qualified : true ) } )";
905+
906+ public string QualifiedName => $ "{ GetType ( ) . GetName ( qualified : true ) } ({ Name } )";
899907
900908 /// <summary>
901909 /// Gets or sets the control's internal name.
902910 /// </summary>
903- public string ? Name
911+ public string Name
904912 {
905- get => _name ;
913+ get => _name ?? $ "(unnamed { GetType ( ) . Name } )" ;
906914 set => _name = value ;
907915 }
908916
@@ -1304,7 +1312,7 @@ public void LoadJsonUi(GameContentManager.UI stage, string? resolution = default
13041312 catch ( Exception exception )
13051313 {
13061314 //Log JSON UI Loading Error
1307- throw new Exception ( "Error loading json ui for " + CanonicalName , exception ) ;
1315+ throw new Exception ( "Error loading json ui for " + ParentQualifiedName , exception ) ;
13081316 }
13091317 }
13101318
@@ -2423,7 +2431,7 @@ public virtual bool SetBounds(int x, int y, int width, int height)
24232431 {
24242432 ApplicationContext . CurrentContext . Logger . LogWarning (
24252433 "Extremely large component resize '{ComponentName}' {OldBounds} => {NewBounds}" ,
2426- CanonicalName ,
2434+ ParentQualifiedName ,
24272435 oldBounds . Size ,
24282436 newBounds . Size
24292437 ) ;
@@ -2959,16 +2967,25 @@ protected bool PlaySound(string? name)
29592967
29602968 public bool IsActive
29612969 {
2962- get => _mouseButtonPressed . GetValueOrDefault ( MouseButton . Left , false ) ;
2963- set => _mouseButtonPressed [ MouseButton . Left ] = value ;
2970+ get => IsMouseButtonActive ( MouseButton . Left ) ;
2971+ set
2972+ {
2973+ if ( value )
2974+ {
2975+ _mouseButtonPressed . Add ( MouseButton . Left ) ;
2976+ }
2977+ else
2978+ {
2979+ _mouseButtonPressed . Remove ( MouseButton . Left ) ;
2980+ }
2981+ }
29642982 }
29652983
2966- public bool IsMouseButtonActive ( MouseButton mouseButton ) =>
2967- _mouseButtonPressed . GetValueOrDefault ( mouseButton , false ) ;
2984+ public bool IsMouseButtonActive ( MouseButton mouseButton ) => _mouseButtonPressed . Contains ( mouseButton ) ;
29682985
2969- private readonly Dictionary < MouseButton , bool > _mouseButtonPressed = [ ] ;
2986+ private readonly HashSet < MouseButton > _mouseButtonPressed = [ ] ;
29702987
2971- public IReadOnlyDictionary < MouseButton , bool > MouseButtonPressed => _mouseButtonPressed ;
2988+ public IReadOnlySet < MouseButton > MouseButtonPressed => _mouseButtonPressed ;
29722989
29732990 protected virtual void OnMouseClicked ( MouseButton mouseButton , Point mousePosition , bool userAction = true )
29742991 {
@@ -2995,7 +3012,7 @@ internal void InputMouseButtonState(MouseButton mouseButton, Point mousePosition
29953012 var wasActive = IsMouseButtonActive ( mouseButton ) ;
29963013 if ( pressed )
29973014 {
2998- _mouseButtonPressed [ mouseButton ] = true ;
3015+ _mouseButtonPressed . Add ( mouseButton ) ;
29993016 InputHandler . MouseFocus = this ;
30003017
30013018 if ( ! wasActive )
@@ -3018,8 +3035,17 @@ internal void InputMouseButtonState(MouseButton mouseButton, Point mousePosition
30183035 }
30193036 }
30203037
3021- _mouseButtonPressed [ mouseButton ] = false ;
3022- InputHandler . MouseFocus = null ;
3038+ _mouseButtonPressed . Remove ( mouseButton ) ;
3039+
3040+ if ( _mouseButtonPressed . Count < 1 )
3041+ {
3042+ // Only replace focus if no mouse buttons are pressed
3043+ // ApplicationContext.CurrentContext.Logger.LogTrace(
3044+ // "Setting MouseFocus to null from {NodeName}",
3045+ // CanonicalName
3046+ // );
3047+ InputHandler . MouseFocus = null ;
3048+ }
30233049
30243050 if ( wasActive )
30253051 {
@@ -4167,7 +4193,7 @@ protected virtual bool OnKeyTab(bool down, bool shift = false)
41674193
41684194 if ( next is { IsTabable : true , IsDisabledByTree : false , IsHiddenByTree : false } )
41694195 {
4170- Console . WriteLine ( $ "Focusing { next . CanonicalName } ({ next . GetFullishName ( ) } )") ;
4196+ Console . WriteLine ( $ "Focusing { next . ParentQualifiedName } ({ next . GetFullishName ( ) } )") ;
41714197 next . Focus ( moveMouse : next is not TextBox ) ;
41724198 }
41734199
0 commit comments