Creating triggers for application actions

Every application action must have a trigger so that users are able to perform it.

There are 6 ways to create a trigger for an action:

  1. automatically,
  2. via LFD widgets,
  3. by ui methods,
  4. in an .fm2 form directly,
  5. in a master or user action defaults file, or
  6. in SystemActionDefaults.fm2.

From the point of visual representation and user interaction, all triggers are the same – regardless of the way they were created by.

What is different is how they are processed and their data is stored by Lycia.

This means that even though end users of your application will see no difference, you will use different methods to manipulate different triggers.

We do not recommend mixing different ways of creating triggers for one application.

You work on the application will be quicker and easier if you choose one way and use it to create all triggers.

Creating a trigger for an action automatically

If an action is not associated with any trigger, Lycia will create it automatically in the form of a toolbar button:

...

ON ACTION act1

  DISPLAY "one"

...

At runtime,

4gl developers can manipulate automatically created triggers by these functions:

For example,

CALL fgl_setactionlabel("act1", "one", "qx://application/filter_1.svg", 1, FALSE, "This is a toolbar button #1", "top")

...

ON ACTION act1

  DISPLAY "one"

...

Creating a trigger for an action as a widget

The usual way to create a trigger for an action is to add a corresponding widget to an .fm2 form.

Most often, actions are triggered by these widgets:

You can also use these widgets to trigger an action:

BlobViewer

Calendar

Canvas

CheckBox

ComboBox

FunctionField

Label

ListBox

RadioGroup

Slider

Spinner

TextArea

TextField

TimeEditField

WebComponent

To use a widget as a trigger for the action, you must follow these steps:

  1. Think about the actions you need to perform and invent their names (=identifiers).
  2. Choose what widget you want to use to trigger this action.

Now the trigger is added to the form and action can be performed at runtime:

4gl developers can manipulate these widget triggers by their properties (as shown above) or via the corresponding ui methods.

 

Creating a trigger for an action by ui methods

This way is close to the previous one but requires a certain level of 4gl expertise.

To be able to create triggers in this way, you must know how to create and manipulate the elements of the ui.<Widget> data type and how to use different ui methods.

You can read about ui methods and elements in the page of the corresponding widget. For example, ui.Button or ui.MenuCommand.

To create a trigger for the action by ui methods, you must follow these steps:

  1. Think about the actions you need to perform and invent their names (=identifiers).
  2. Choose what widget you want to use to trigger this action.

4gl developers can manipulate these triggers by the corresponding ui methods (e.g., setText(), setImage(), setTooltip(), etc).

 

Creating a trigger for an action directly in an .fm2 form

Every form element of a .fm2 form file has a property, actions, that allows creating triggers for application actions:

This property has all the attributes of the trigger:

To create a trigger for the action in a .fm2 form directly, you must follow these steps:

  1. Think about the actions you need to perform and invent their names (=identifiers).
  2. Specify its identifier – to associate the trigger with a definite property, you must use the same name as in the 4gl code.

More details about the property, actions, is here.

Creating a trigger for an action in system, master, and user action defaults files

SystemActionDefaults.fm2 is an editable global configuration file containing the predefined application actions, i.e. the application actions applied to all Lycia-based 4gl applications.

Master action defaults file is an action defaults file that contains default attributes for actions that can be performed in the 4gl application. Master action defaults files have the name of the program, are stored together with it, and are loaded automatically when the application is run.

User action defaults file is a user-defined configuration file with extension .ad2 or .fm2 that contains default attributes for actions that can be performed in several different 4gl applications in order to secure their common runtime behavior or change it according to current tasks and purposes.

All these files have the same basic structure as any .fm2 form including the property, actions, that is used to create triggers for the application actions.

The algorithm of creating a trigger for an application action in an action defaults file is almost the same as in the .fm2 form directly. The difference is in the scope to which this action will be applied:

To create a trigger for the action in an action defaults file, you must follow these steps:

  1. Think about the actions you need to perform and invent their names (=identifiers).
  2. Open with the administrator privileges (S, u, m) or create (u, m) the necessary action defaults file.
  3. Specify its identifier – to associate the trigger with a definite property, you must use the same name as in the 4gl code.

  4. Save the action defaults file.
  5. Rebuild the affected programs.

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.