[GH-ISSUE #427] Feature request: Add getters of colors / attributes for the Box #311

Closed
opened 2026-03-04 01:03:51 +03:00 by kerem · 2 comments
Owner

Originally created by @bry00 on GitHub (Apr 8, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/427

It would be useful when developing custom Widgets based on Box, to have possibility to get current value of properties borderAttributes, borderColor, backgroundColor. Currently, these are in fact, write-only properties, as there is group of "set" functions (SetBorderAttributes, SetBorderColor, SetBackgroundColor) but without their exported "get" counterparts one cannot use easily these values.
It seems to be tiny but useful extension.

Something like this:


// GetBorderAttributes gets the border's style attributes.
func (b *Box) GetBorderAttributes() tcell.AttrMask {
	return b.borderAttributes
}

// GetBorderColor gets the box's border color.
func  (b *Box) GetBorderColor() tcell.Color {
	return b.borderColor
}

// GetBackgroundColor gets the box's background color.
func  (b *Box) GetBackgroundColor() tcell.Color {
	return b.backgroundColor
}

Originally created by @bry00 on GitHub (Apr 8, 2020). Original GitHub issue: https://github.com/rivo/tview/issues/427 It would be useful when developing custom Widgets based on Box, to have possibility to get current value of properties `borderAttributes`, `borderColor`, `backgroundColor`. Currently, these are in fact, write-only properties, as there is group of "set" functions (`SetBorderAttributes`, `SetBorderColor`, `SetBackgroundColor`) but without their exported "get" counterparts one cannot use easily these values. It seems to be tiny but useful extension. Something like this: ```golang // GetBorderAttributes gets the border's style attributes. func (b *Box) GetBorderAttributes() tcell.AttrMask { return b.borderAttributes } // GetBorderColor gets the box's border color. func (b *Box) GetBorderColor() tcell.Color { return b.borderColor } // GetBackgroundColor gets the box's background color. func (b *Box) GetBackgroundColor() tcell.Color { return b.backgroundColor } ```
kerem closed this issue 2026-03-04 01:03:51 +03:00
Author
Owner

@rivo commented on GitHub (Apr 14, 2020):

I added this with the latest commit.

<!-- gh-comment-id:613386969 --> @rivo commented on GitHub (Apr 14, 2020): I added this with the latest commit.
Author
Owner

@bry00 commented on GitHub (Apr 28, 2020):

Super, thx.

<!-- gh-comment-id:620835914 --> @bry00 commented on GitHub (Apr 28, 2020): Super, thx.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#311
No description provided.