Add Fl_Widget::shortcut_label(int) to control effect of '&' in some widget labels

This commit is contained in:
ManoloFLTK 2020-01-26 19:14:45 +01:00
parent d2cb11369c
commit 3384fe93df
7 changed files with 29 additions and 2 deletions

View File

@ -51,7 +51,7 @@ class Fl_Widget_Tracker;
down, but if you have an input field in the same window, the user will have
to hold down the \e Alt key so that the input field does not eat the event
first as an \c FL_KEYBOARD event.
\see Fl_Widget::shortcut_label(int)
\todo Refactor the doxygen comments for Fl_Button type() documentation.
For an Fl_Button object, the type() call returns one of:

View File

@ -79,6 +79,7 @@
UTF-8 sequences and pointers into the middle of a sequence are undefined.
\see Fl_Text_Display, Fl_Text_Editor for more powerful text handling widgets
\see Fl_Widget::shortcut_label(int)
\internal
When porting this widget from ASCII to UTF-8, previously legal pointers into

View File

@ -50,7 +50,7 @@
The line spacing between menu items can be controlled with the global setting
Fl::menu_linespacing().
\see Fl_Widget::shortcut_label(int)
*/
class FL_EXPORT Fl_Menu_ : public Fl_Widget {

View File

@ -41,6 +41,8 @@
on the card tab, including the label font and style. The
selection color of that child is used to color the tab, while
the color of the child determines the background color of the pane.
'&' in labels are used to prefix a shortcut that is drawn underlined and
that activates the corresponding tab; repeated '&&' avoids that.
The size of the tabs is controlled by the bounding box of the
children (there should be some space between the children and

View File

@ -75,6 +75,7 @@
and Fl_Text_Buffer classes.
\note Line numbers were added in FLTK 1.3.3.
\see Fl_Widget::shortcut_label(int)
*/
class FL_EXPORT Fl_Text_Display: public Fl_Group {

View File

@ -52,6 +52,7 @@
<P ALIGN="CENTER">\image html Fl_Value_Input.png
\image latex Fl_Value_Input.png "Fl_Value_Input" width=4cm
\see Fl_Widget::shortcut_label(int)
*/
class FL_EXPORT Fl_Value_Input : public Fl_Valuator {
public:

View File

@ -1042,6 +1042,28 @@ public:
\deprecated Use selection_color(unsigned) instead.
*/
void color2(unsigned a) {color2_ = a;}
/** Sets whether the widget's label use '&' to indicate shortcuts.
By default, all objects of classes Fl_Menu_ (and derivatives), Fl_Button (and derivatives),
Fl_Text_Display, Fl_Value_Input, and Fl_Input_ (and derivatives)
use character '&' in their label, unless '&' is repeated,
to indicate shortcuts: '&' does not appear in the drawn label,
the next character after '&' in the label is drawn underlined, and typing this character
triggers the corresponding menu window, button, or other widget. If the label contains 2 consecutive '&',
only one is drawn and the next character is not underlined and not used as a shortcut.
If \p value is set to 0, all these labels don't process character '&' as indicating a shortcut:
'&' is drawn in the label, the next character is not underlined and does not define a shortcut.
*/
void shortcut_label(int value) {
if (value)
set_flag(SHORTCUT_LABEL);
else
clear_flag(SHORTCUT_LABEL);
}
/** Returns whether the widget's label use '&' to indicate shortcuts.
\see void shortcut_label(int value) */
int shortcut_label() const { return flags_ & SHORTCUT_LABEL; }
};
/**