Using Functions to Manipulate Toolbar at Runtime

MAIN

    DEFINE hidden integer

    LET hidden = 0

    

    OPEN WINDOW new_win WITH 5 ROWS, 80 COLUMNS

    

    MENU "m1"

    

    BEFORE MENU

       CALL fgl_setactionlabel("ActName1","Sh Act Lbl", "", 10, TRUE, "Show Action Label")

       CALL fgl_setactionlabel("ActName2","Sh/Hide Key", "", 20, TRUE, "Show/Hide Static Key")

       CALL fgl_setactionlabel("ActName3","Set New Lbl", "", 30, TRUE, "Set new Action Label")

       CALL fgl_setkeylabel("F2","F2", "", 40, FALSE, "F2 - Set Keydivider")   

       

    ON ACTION "ActName1"

        MESSAGE "Action label is: ",fgl_getactionlabel("ActName1")  

    ON ACTION "ActName2"

        IF hidden = 0

        THEN

          CALL fgl_setkeylabel("CONTROL-A","CTRL-A", "", 50, TRUE, "Show/Hide Static Key")

          LET hidden = 1

          MESSAGE "Key label is: ",fgl_getkeylabel("F2")

        ELSE

          CALL fgl_setkeylabel("CONTROL-A","CTRL-A", "", 50, FALSE, "Show/Hide Static Key")

          LET hidden = 0

          MESSAGE "Hidden Key label is: ",fgl_getkeylabel("F2")

        END IF

    ON ACTION "ActName3"

        CALL fgl_setactionlabel("ActName3","New Label", "", 30, TRUE, "Set new Action Label")

    

    COMMAND KEY (F2)

    -- Action will be invoked by pressing F2, the focus must be in the current window

        CALL fgl_keydivider(15)

        CALL fgl_keydivider(25)

        CALL fgl_keydivider(35)

        CALL fgl_keydivider(45)

        CALL fgl_keydivider(55)

        

    COMMAND "exit"

        EXIT MENU

    END MENU

END MAIN