fgl_setkeylabel()

 

Assigns a label to a key in the global scope.

 

Syntax:

 

CALL fgl_setkeylabel("KeyName" STRING, "KeyLabel" STRING, "icon" STRING, Order# INTEGER, IsStatic BOOLEAN, "ToolTip" STRING)

 

Arguments:

 

1. Key Name

The name of the key.

2. Label

The label name. 

3. Icon (Optional)

A relative (../images/icon.png) or absolute path (qx://application/querixlogo.png) to an icon. If the icon file is not attached to the program, it won’t be displayed to the label.

4. Order (Optional)

An integer value or variable value  which indicates where the label will be positioned on the toolbar.

5. IsStatic (Optional)

Defines if a key label is visible, even if a default action cannot be triggered at the moment.

The default value is FALSE.

6. Tooltip (Optional)

Tooltip information is shown when the cursor points to a label.

 

Usage and examples:

 

The fgl_setkeylabel() allows to create toolbars dynamically and automatically in the global scope.

 

Here is an example, which shows how to set key labels:

 

MAIN

DEFINE s STRING

    OPEN FORM f FROM "myForm"

    DISPLAY FORM f

        CALL fgl_setkeylabel("F1","F1 toolbarKey", "images/css-24.png", 3, TRUE, "tooltip")

        CALL fgl_setkeylabel("F2","F2 toolbarKey", "qx://application/ico/f2.ico", 4, FALSE, "tooltip")

        CALL fgl_setkeylabel("Esc","EXIT")

    INPUT s FROM field1

    BEFORE INPUT

          ON KEY(F1)

             DISPLAY "F1_txt"

          ON KEY(F2)

             DISPLAY "F2_txt"

          ON KEY(Esc)

          EXIT PROGRAM

    END INPUT   

END MAIN

 

If you want to hide the label and/or the icon, you can call this function as shown below.

 

CALL fgl_setkeylabel("F2", "")

 

The event assigned to the toolbar button will be still triggered, if the key specified in the function is pressed, even though the button is invisible. The event will be disabled only if the specified key is not referenced in the code (e.g. there is no COMMAND or ON KEY clause for this key in the executed code).

 

 

Related articles:

Action Basics

List of Predefined Actions

fgl_dialog_setactionlabel()

fgl_setkeylabel()

fgl_getkeylabel()

Using Functions to Manipulate Toolbar at Runtime