inputfieldsandbuttons.C creates three buttons at the bottom of the window, using a factory's create_button() method which returns a new x::w::button.

create_button()'s first parameter is a x::w::text_param that's constructible from a plain text string, but also offers the means of specifying fonts and colors. inputfieldsandbuttons.C demonstrates how to use an alternative create_button() overload that uses a factory to create the Ok button's content:

     (const x::w::factory &f)


This overload takes a single lambda or a callable object as a parameter. The lambda receives another factory as its sole argument, and is expected to use that factory to create a single display element. This becomes the contents of the button. Like all display elements they must be show()n in order to be visible.

The create_button() that takes a text string parameter is just a wrapper that uses create_label() to put the label into the button, and show() it, like demonstrated by inputfieldsandbuttons.C.

create_button's optional second parameter specifies non-default button settings and configurations:


This second parameter is a template that takes a variadic list of values, and the simplest approach is to simply use the uniform initialization syntax to construct the parameter object. Multiple values must appear in the following order:


This value is only allowed as an option when create_button()'s first parameter is a x::w::text_param. This value gets forwarded to create_label when creating the new button's label.


This setting specifies the button's visual appearance. The default value for this setting gets returned by x::w::normal_button(). This results in a regular button, with a normal border.

x::w::default_button() returns an alternative appearance with a thicker border; typically for a window's default button that gets activated by Enter key.


A keyboard shortcut.

There are several ways to activate a button:

Shortcut activation

A keyboard shortcut gets recognized only if the key combination does not get processed by the field with the current keyboard input focus. inputfieldsandbuttons.C sets shortcuts for all three buttons it creates: Esc for the Cancel button, ALT-R for the Reset button, and Enter for the Ok button, but the Enter shortcut only works when the keyboard focus is in the first text input field (or no input field has keyboard focus).

When the current keyboard input focus is in the second text input field, Enter inserts a new row. When it's in any button, Enter activates that button. A keyboard shortcut takes effect only if its key does not result in any other action.