tview icon indicating copy to clipboard operation
tview copied to clipboard

Add support for displaying text next to a checkbox

Open berrange opened this issue 6 years ago • 3 comments

When building forms the label field is typically quite short, just one or two words. For checkboxes it is often desirable to have a longer descriptive piece of text. This is not practical to use as a label and in many applications would more commonly be placed to the right of the checkbox.

This adds support for a "SetMessage()" method which provides support for text adjacent to the checkbox

As an example, this form shows one usage pattern, where the checkbox is used to require case sensitive matching of the author name query. In this case the checkbox label is an empty string, and the message text is used instead:

 ╔════════════ User filtering ════════════════════╗
 ║                                                ║
 ║    Age:   ________                             ║
 ║                                                ║
 ║ Author:   ______________                       ║
 ║                                                ║
 ║           X Case sensitive                     ║
 ║                                                ║
 ║   Apply     Cancel                             ║
 ╚════════════════════════════════════════════════╝

Another pattern is where there are a series of checkboxes, all related to the same attribute. Thus they have a common form label but different message text

 ╔════════════ Request filtering ═════════════════╗
 ║                                                ║
 ║    State:    X Opened                          ║
 ║                                                ║
 ║              _ Closed                          ║
 ║                                                ║
 ║              _ Merged                          ║
 ║                                                ║
 ║              X Locked                          ║
 ║                                                ║
 ║   Apply     Cancel                             ║
 ╚════════════════════════════════════════════════╝

Signed-off-by: Daniel P. Berrangé [email protected]

berrange avatar Nov 14 '19 11:11 berrange

Tested and merged into cview with this additional commit adding a message argument to Form.NewCheckbox

tslocum avatar Jan 17 '20 23:01 tslocum

Updated the patch to apply to current git master

berrange avatar Nov 25 '21 17:11 berrange