Skip to content

4. Life cycle of a button

Gary Criblez edited this page Jun 26, 2020 · 2 revisions

Phase 1 : initialization and configuration

The first step is to define the properties of the button that will be displayed. To do this, the component provides a "New AJUI_Button" method generating a base object representing a default definition. Then the user is free to use the member functions attached to the object to customize its properties as he likes.

Form.btn1:=New AJUI_Button
Form.btn1.Name("btn1")

  //default
Form.btn1.BGColor(AJUI_btn_default;"lightgrey")
Form.btn1.Label AJUI_btn_default(;"BTN 1")
Form.btn1.BorderSize(AJUI_btn_default;2)

  //hover
Form.btn1.BGColor(AJUI_btn_hover;"darkgrey")
Form.btn1.Label(AJUI_btn_hover;"On Hover")

  //active
Form.btn1.BGColor(AJUI_btn_active;"grey")
Form.btn1.Label(AJUI_btn_active;"On Clicked")

This step is very important, because all the other steps will be based on what has been defined in the object.

Phase 2 : Calculations and button generation

The second phase that is the most significant for the component is the creation of the button based on its definition. During this phase, it will be in charge of retrieving the object's properties in order to perform a series of calculations and controls in order to generate/assign the different elements that will compose this set called the button. It is also in this phase that exceptions related to the state are processed. If a callback is assigned and the event corresponds to it, it will be executed at the end of the generation.

Phase 3 : Showing and Hiding

At the end of the generation, the picture is assigned to the picture form object that has been associated with it. The button display is managed using the "Show" and "Hide" member functions or using 4D methods to manage form objects.