Creating the standard input focus frame display element

customkeyfocus.C's custom display element's default appearance is plain and unadorned. LibCXXW's standard display elements visually indicate which one has keyboard input focus frame by drawing a border around that display element. This is not something that happens automatically. Each display element has full control over its appearance.

customkeyfocus.C custom display element changes its background color when it has input focus. Running customkeyfocus with the -f option also draws the standard input focus frame.

An input focus frame is a container. LibCXXW's display elements are arranged in a logical hierarchy of containers, and a container itself is a display element; namely a display element that contains other display elements. An input focus frame is a container that draws a input focus border around the display element inside the container.

A brief overview of a process for creating a custom display element:

  1. Use a factory's get_container_impl() to obtain the new custom element's parent container implementation object.

  2. Create the custom element's implementation object instance, passing to it the parent container's implementation object.

  3. Create the public object for the custom element's implementation object.

  4. Pass the new public object to the factory's created_internally() method.

Use the following process for creating a custom focusable element with an input focus frame.

  1. Use a factory's get_container_impl() to obtain the new custom element's parent container implementation object.

  2. Create an implementation object for the input focus frame's container.

  3. Create the custom element's implementation object instance, passing to it the input focus frame container's implementation object.

  4. Create the public object for the custom element's implementation object.

  5. Create the public object for the input focus frame, using x::w::create_focusframe_container(), which takes care of logically using created_internally() with the custom element's public object.

  6. Pass the input focus frame's public object to the factory's created_internally() method.

This logically translates to a minor sleight of hand. Instead of creating a custom display element for the factory in question, the input focus frame display element gets created. That becomes the new display element. But the real custom display element goes into the input focus frame, which is a container.