FontChooser Utility Class

Description

In BBj 12.0 and higher, the FontChooser utility class is a BBj custom class that acts as a wrapper around the BBjFontChooser. It uses group namespace variables for returning results.

Public Constructors

FontChooser(BBjFont startFont!, BBjNumber startX, BBjNumber startY, BBjString nsVar$)

Variable

 Description

startFont!

Initial BBjFont the FontChooser should select when invoked.

startX

Left coordinate at which to position the dialog or -1 (default) to have dialog centered horizontally.

startY

Upper coordinate at which to position the dialog or -1 (default) to have the dialog centered vertically.

nsVar$

Group namespace variable name in which to return the resultant selection and the base name in which to return the user’s action.

Public Fields

There are no public fields.

Public Methods

Return Type

Method

Description

BBjFont

getSelectedFont()

Returns the selected font.

void

showFontInfo(BBjFont font!)

Presents a BBj message box showing the current name, style and size in the passed BBjFont.

void

approve(BBjFontChooserApproveEvent ev!)

Method invoked when the user hits the [OK] button.

Sets the group namespace variable’s value to the selected font.

Sets the group namespace variable + "_user_action" to “::SELECT::”.

void

cancel(BBjFontChooserCancelEvent ev!)

Method invoked when the user presses the [Cancel] button or closes the dialog.

Sets the group namespace variable’s value to null().

Sets the group namespace variable + "_user_action" to “::CANCEL::”.

void

closeWindow(BBjCloseEvent ev!)

Method invoked when the user closes the dialog, thereby canceling any selection.

Invocation

This BBj custom class may be instructed to handle events itself or not. By default, events are not handled by the class, but left to the calling process. In order to have the class handle events itself, set the value of the group namespace variable passed in the constructor to “process_events“ before instantiating the class.

The FontChooser utility class contains an example of using it at the end of the program file “FontChooser.bbj” found in the utils directory under the BBj installation. Invoke it by simply running “FontChooser.bbj”.

Also contained in the FontChooser directory is a test program showing how to invoke the FontChooser in "CUI" style. The FontChooser class is instructed to invoke process_events.

See Also

BBjFontChooser