Buttons

inputfieldsandbuttons.C creates three buttons at the bottom of the window, using a factory's create_normal_button_with_label() and create_special_button_with_label() methods. The only difference between normal and special buttons is the buttons' border: a normal border, and a thick border. In all other respects, there is no difference between a normal and a special x::w::button.

A factory also offers more generic create_normal_button() and create_special_button() methods. inputfieldsandbuttons.C creates ordinary buttons with a simple text label inside them, but a button's contents are arbitrary:

factory->create_normal_button([]
     (const x::w::factory &f)
     {

     });

create_normal_button() and create_special_button() take a single lambda 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.

create_normal_button_with_label() and create_special_button_with_label() are simply wrappers that use create_label() to put the label into the button, and show() it.

An optional second parameter specifies the button's keyboard shortcut, this is a x::w::shortcut object. 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.