ToolbarButton

Form and theme XML code and CSS element selector

Inheritance diagram

Most commonly used form and theme properties

Associated 4gl syntax, functions, and ui methods

Influence and behavior

Lycia is going to move to Material Design.

Some of the features described below are available only for the material-design version of Lycia.

ToolbarButton is a button on a toolbar which is used to invoke actions.

ToolbarButton can include labels, icons, or tooltips.

Toolbar with 2 toolbar buttons and a separator inserted in a Grid panel as seen in Lycia Form Designer

Form XML code:

<ToolbarButton text="tbButton 1" visible="true" identifier="tbButton1">

   <ToolbarButton.onInvoke>

      <ActionEventHandler type="actioneventhandler" actionName="actTbButton"/>

   </ToolbarButton.onInvoke>

</ToolbarButton>  

Theme element filter XML code:

<ElementFilter ElementName="ToolbarButton">

   ...

</ElementFilter>

CSS element selector code:

qx-aum-toolbar-button

Inheritance diagram:

Most commonly used form properties:

classnames

Events: OnInvoke

identifier

image

preferredSize

text

tooltip

Most commonly used theme properties:

Image:

New Image

Image Url

Image Scaling

Image Position

Size

Associated 4gl syntax:

INPUT 

Associated functions:

fgl_setactionlabel()

fgl_getactionlabel()

fgl_setkeylabel()

fgl_getkeylabel()

fgl_dialog_setactionlabel()

fgl_dialog_getactionlabel()

fgl_dialog_setkeylabel()

Associated ui methods:

SetAllowNewLines 

GetAllowNewLines

SetIdentifier 

GetIdentifier 

SetText 

GetText

Influence and behavior:

To add a ToolbarButton to your form,

Step 1. Choose a ToolbarButton from the widgets palette by left-clicking its icon.

Step 2. Left-click the toolbar to place the ToolbarButton there.

Step 3. The ToolbarButton is now added to your form, and you can see it in the Structure view.

 

To make toolbar buttons active and trigger an event only when focus is a definite field,

4gl code sample:

MENU

  COMMAND "input"

    INPUT BY NAME f1

      ON ACTION "show_yes" INFIELD f1

        DISPLAY "yes"

      ON ACTION "show_no" INFIELD f1

        DISPLAY "no"

    END INPUT

  COMMAND "exit"

    EXIT MENU

END MENU

runtime behavior:

 

At runtime, toolbar buttons can be manipulated with ui methods.

Here you can find out how to enable or disable tooltips at runtime using the setTooltip() method:

 

You can change appearance properties of a ToolbarButton in Lycia Form Designer. However, we recommend applying appearance properties via user themes and css.

To apply a property to a ToolbarButton, set its value in the user theme, directly or using filters.

In the example below, we specify the appearance of toolbar buttons by applying Fill Color property.

lycia theme designer

theme XML code

<?xml version="1.0" encoding="utf-8"?>

<StyleSheet xmlns="http://querix.com">

  <ElementFilter ElementName="ToolbarButton">

    <StyleSheet>

      <DoStyleAction>

        <SetProperty>

          <PropertyPath>

            <PropertyName>Background</PropertyName>

            <PropertyName>FillColor</PropertyName>

          </PropertyPath>

          <PropertyValue type="CustomizedColor" RedColor="120" GreenColor="144" BlueColor="156" Alpha="255" />

        </SetProperty>

      </DoStyleAction>

    </StyleSheet>

  </ElementFilter>

</StyleSheet>

runtime appearance

 

Appearance and behavior of toolbar buttons depend on the Lycia version you use – jquery Lycia or Lycia with Material Design.

Here are the rules which are applied to toolbar buttons with MD Lycia:

All these rules apply to both toolbar buttons created via the ToolbarButton widget, dynamically (by the corresponding ui methods), and by ON ACTION and COMMAND clauses (e.g., of the MENU statement).

The difference between these two types of toolbar buttons (in relation to MD Lycia) lies in how you set their text and icon:

 

With MD Lycia, if a toolbar includes more than 6 toolbar buttons, these buttons are rendered to the drop-down menu.

There are 5 ways to render the necessary toolbar buttons to the navigation bar:

 

At runtime, you can create and manipulate toolbar buttons with ui methods.

You cannot create a Toolbar widget by ui methods – only the ToolbarButton widget.

If your .fm2 form has a Toolbar widget, you can populate it via ui methods:

DEFINE tb_group ui.ToolbarGroup

DEFINE tb_button ui.ToolbarButton

...

LET tb_group = ui.ToolbarGroup.Create("tbg","toolbar")

LET tb_button = ui.ToolbarButton.Create("bt1","tbg")

CALL tb_button.SetText("form button")

To make this newly created toolbar button able to trigger any actions, you must set the event for it:

DEFINE buttonEvent ui.BackgroundServerEventHandler

...

LET buttonEvent = ui.BackgroundServerEventHandler.Create()

CALL buttonEvent.SetCallBackAction("display")

CALL tb_button.SetOnInvoke(buttonEvent)

So the simple algorithm for adding toolbar buttons by ui methods is this:

  1. Check that your form has a Toolbar widget.
  2. Define variables of ui.ToolbarGroup, ui.ToolbarButton, and ui.BackgroundServerEventHandler data types in your 4gl code.
  3. Use the create() method to create a toolbar group.
  4. Use the create() method to create a toolbar button. Make sure that you have specified the correct toolbar group.
  5. Set the event for this toolbar button.

 

All properties of a toolbar button can be changed at runtime by ui methods.

For example,

 

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.