@@ -49,6 +49,7 @@ public class ButtonControl : BaseControl, IInteractiveControl, IFocusableControl
4949 private Color ? _disabledBackgroundColor ;
5050 private Color ? _disabledForegroundColor ;
5151 private Color ? _borderColor ;
52+ private Color ? _borderBackgroundColor ;
5253
5354 /// <summary>
5455 /// Initializes a new instance of the ButtonControl class with default settings.
@@ -163,6 +164,16 @@ public Color? BorderColor
163164 set => SetProperty ( ref _borderColor , value ) ;
164165 }
165166
167+ /// <summary>
168+ /// Gets or sets the background color for border cells.
169+ /// When null, uses the button's resolved background color.
170+ /// </summary>
171+ public Color ? BorderBackgroundColor
172+ {
173+ get => _borderBackgroundColor ;
174+ set => SetProperty ( ref _borderBackgroundColor , value ) ;
175+ }
176+
166177 /// <inheritdoc/>
167178 public bool ProcessKey ( ConsoleKeyInfo key )
168179 {
@@ -334,6 +345,7 @@ public override void PaintDOM(CharacterBuffer buffer, LayoutRect bounds, LayoutR
334345 }
335346
336347 Color borderFg = _borderColor ?? foregroundColor ;
348+ Color borderBg = _borderBackgroundColor ?? backgroundColor ;
337349 int targetWidth = bounds . Width - Margin . Left - Margin . Right ;
338350 if ( targetWidth <= 0 ) return ;
339351
@@ -389,35 +401,35 @@ public override void PaintDOM(CharacterBuffer buffer, LayoutRect bounds, LayoutR
389401 var box = _borderStyle == ButtonBorderStyle . Rounded ? BoxChars . Rounded : BoxChars . Single ;
390402 if ( row == 0 )
391403 {
392- buffer . SetNarrowCell ( bx , y , box . TopLeft , borderFg , backgroundColor ) ;
404+ buffer . SetNarrowCell ( bx , y , box . TopLeft , borderFg , borderBg ) ;
393405 for ( int x = 1 ; x < buttonWidth - 1 ; x ++ )
394- buffer . SetNarrowCell ( bx + x , y , box . Horizontal , borderFg , backgroundColor ) ;
395- buffer . SetNarrowCell ( bx + buttonWidth - 1 , y , box . TopRight , borderFg , backgroundColor ) ;
406+ buffer . SetNarrowCell ( bx + x , y , box . Horizontal , borderFg , borderBg ) ;
407+ buffer . SetNarrowCell ( bx + buttonWidth - 1 , y , box . TopRight , borderFg , borderBg ) ;
396408 }
397409 else if ( row == 2 )
398410 {
399- buffer . SetNarrowCell ( bx , y , box . BottomLeft , borderFg , backgroundColor ) ;
411+ buffer . SetNarrowCell ( bx , y , box . BottomLeft , borderFg , borderBg ) ;
400412 for ( int x = 1 ; x < buttonWidth - 1 ; x ++ )
401- buffer . SetNarrowCell ( bx + x , y , box . Horizontal , borderFg , backgroundColor ) ;
402- buffer . SetNarrowCell ( bx + buttonWidth - 1 , y , box . BottomRight , borderFg , backgroundColor ) ;
413+ buffer . SetNarrowCell ( bx + x , y , box . Horizontal , borderFg , borderBg ) ;
414+ buffer . SetNarrowCell ( bx + buttonWidth - 1 , y , box . BottomRight , borderFg , borderBg ) ;
403415 }
404416 else
405417 {
406- buffer . SetNarrowCell ( bx , y , box . Vertical , borderFg , backgroundColor ) ;
418+ buffer . SetNarrowCell ( bx , y , box . Vertical , borderFg , borderBg ) ;
407419 string padded = $ " { new string ( ' ' , leftInnerPad ) } { text } { new string ( ' ' , rightInnerPad ) } ";
408420 var cells = Parsing . MarkupParser . Parse ( padded , foregroundColor , backgroundColor ) ;
409421 buffer . WriteCellsClipped ( bx + 1 , y , cells , clipRect ) ;
410- buffer . SetNarrowCell ( bx + buttonWidth - 1 , y , box . Vertical , borderFg , backgroundColor ) ;
422+ buffer . SetNarrowCell ( bx + buttonWidth - 1 , y , box . Vertical , borderFg , borderBg ) ;
411423 }
412424 }
413425 else if ( _borderStyle == ButtonBorderStyle . Pipe )
414426 {
415427 // │ text │
416- buffer . SetNarrowCell ( bx , y , BoxChars . Single . Vertical , borderFg , backgroundColor ) ;
428+ buffer . SetNarrowCell ( bx , y , BoxChars . Single . Vertical , borderFg , borderBg ) ;
417429 string padded = $ " { new string ( ' ' , leftInnerPad ) } { text } { new string ( ' ' , rightInnerPad ) } ";
418430 var cells = Parsing . MarkupParser . Parse ( padded , foregroundColor , backgroundColor ) ;
419431 buffer . WriteCellsClipped ( bx + 1 , y , cells , clipRect ) ;
420- buffer . SetNarrowCell ( bx + buttonWidth - 1 , y , BoxChars . Single . Vertical , borderFg , backgroundColor ) ;
432+ buffer . SetNarrowCell ( bx + buttonWidth - 1 , y , BoxChars . Single . Vertical , borderFg , borderBg ) ;
421433 }
422434 else
423435 {
0 commit comments