The [floatMenu] command.

Introduction

The floatMenu command lets you create and manipulate floating menus in Alpha.
Floating menus are like floating palettes which reproduce the contents of any menu in Alpha: for any item in the menu, there is a corresponding button in the floating palette, and clicking on the button is equivalent to selecting the item in the menu. In the rest of this page, the expressions palette or floating menu are synonymous.

Synopsis

The formal syntax of the [floatMenu] command is:
floatMenu subcommand ?options?
The possible subcommands are described below. Depending on the subcommand, some options may be specified.

FloatMenu subcommands

The [create] subcommand

This subcommand creates a floating menu from an existing menu. It accepts a wide variety of options. The complete syntax is:
    floatMenu create -menu menuToken [(-align|-height|-width|-left|-top|-max|-interspace) val] \
         [-name winname] [-dynamic (0|1)] [-visible (0|1)]
The command returns a token used in the other subcommands to uniquely identify the floating menu. This token must not be confused with the token of the menu with which the floating palette is associated.
The possible options are described in the Floating menu options section below. By default, a floating window is made visible when it is created unless the -visible option was specified with value 0. The -menu is required on creation.

The [delete] subcommand

This subcommand lets you delete a floating menu. This is equivalent to closing the floating window with a mouse click in the Close box. The syntax is:
    floatMenu delete token

The [find] subcommand

This subcommand lets you find the floating palette associated with a given menu. The syntax is:
    floatMenu find menuToken
If there is a floating palette associated with the menu specified in the menuToken argument, the command returns the palette's token. Otherwise it raises an error. This command can be useful to test the existence of a floating window.

The [hide] subcommand

This subcommand lets you hide a floating menu. The syntax is:
    floatMenu hide token
This subcommand is a convenience: it is equivalent to [floatMenu set] invoked with -visible 0 argument.

The [list] subcommand

This subcommand returns a list of the tokens corresponding to the currently existing floating menus. Each time a new floating menu is created, its token is appended at the end of the list, so this list is ordered from the oldest to the newest float. The syntax is:
    floatMenu list

The [move] subcommand

This subcommand lets you reposition a floating menu on the screen. The syntax is:
    floatMenu move token left top
where left and top designate the position of the upper left corner of the float in screen coordinates.

The [refresh] subcommand

This subcommand lets you refresh the buttons of an already existing floating menu. The syntax is:
    floatMenu refresh token

The [set] subcommand

This subcommand lets you get or set several properties attached to a menu item. The syntax can take two forms:
    floatMenu set token option
    floatMenu set token option value ?option value...?
In the first form the command returns the current value of the specified option. In the second form, it lets you set the value of one or several options.
The possible options are described in the Floating menu options section below.
Note that it is not possible to reset the menu attached to a floating palette, i-e the -menu option is not accepted in the second form of this subcommand.

The [show] subcommand

This subcommand is the opposite of the [hide] subcommand. It lets you display an existing floating menu if it is hidden.
    floatMenu show token
This subcommand is a convenience: it is equivalent to [floatMenu set] invoked with -visible 1 argument.

The [top] subcommand

This subcommand gets or sets the topmost floating menu. The syntax is:
    floatMenu top 
    floatMenu top token
In the first form, it returns the token of the topmost floating palette or an empty string if there is none. In the second form, it brings the float corresponding to the token argument on top of the others.

Floating menu options

The [floatMenu create] and [floatMenu set] commands accept options to set some attributes of the floating menus. The options are explained below.
Note that all the options can be set on creation with the [floatMenu create] command, but only the following options can be modified with [floatMenu set]: -dynamic, -name, -visible, -width.
Here is the description of the various options:
The possible values for the -attr option are additive values among the following:
No Attributes 0
Resizable Window 1
No Vert Scrollbar 2
No Auto Hide Scrollbar4
No Close Button 6
No Title Bar 16

Hooks

There are two hooks named floatHook and unfloatHook which are called respectively when the [floatMenu create] and [floatMenu delete] commands are invoked.
The floatHook proc is invoked when the floating window has been created in memory but before it is attributed its token: so, at this point, the new float would not be listed by the [floatMenu list] command.
The unfloatHook proc is invoked when the floating window has been disposed of. At this point, the floating menu token is no longer valid.

Examples

See examples of use in the test file for the [floatMenu] command located in the application's bundle: floatMenu_test.tcl.

Last updated 2019-10-17 13:29:28