Skip to content

3. Button states

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

An AJUI_button can take on a different appearance and content depending on five states and the exceptions that will be defined for them.

States

State « Default »

This is the basic state of a button when a user does not interact with it or when it is not disabled.

State « Hover »

This state occurs when the "On Mouse Enter" event is triggered and ends with the "On Mouse Leave" event. In concrete terms, the user is hovering over the button with the mouse.

State « Active »

This state intervenes on the "On Click" event and ends with the "On Mouse Up. Note that it has priority over the "Hover" state. In practice, the user clicks on the button and the status lasts until it is released.

State « Disable »

This state takes place when the button is deactivated using the object's "Enable" member function. When the button is deactivated, only this state is taken into account.

State « Focus »

This state occurs on the "On Getting Focus" event and ends with the "On Losing Focus”.

Events and callbacks

As you can see from the states, the component requires that several events be activated on the picture form object in order to be able to manage the different states. Here is the list of these :

  • On Load
  • On Click
  • On Double Click (optionnel)
  • On Mouse Enter
  • On Mouse Leave
  • On Mouse Up
  • On Getting Focus
  • On Losing Focus

Concerning the two events on click and on double-click, callbacks can be associated with them using the member functions. Basically, the event on the double-click is not necessary unless you use the callback.

⚠️ All methods used as callbacks must be shared (method properties) with the component so it can call it. To prevent an error from occurring in such case, the component will check if the method is well shared and if it is not, it will share it itself when executing a callback. In addition, the component will propose to create the callback method if it does not exist when using Setters for callbacks and also before executing a callback.

The notion of exception and the constants of the component

In order to be able to modify the structure and content of a button, we have set up an exception mechanism in the component that will apply to all states except "Default" which retains all its basic properties.

To do this, most of the member functions (see the list of properties for details) expect a constant in the first parameter. Each constant represents one of the five states. Here is the list:

  • AJUI_btn_default (no exceptions created)
  • AJUI_btn_hover
  • AJUI_btn_active
  • AJUI_btn_disable
  • AJUI_btn_focus

According to the constant that you will pass to a member function, it will create an exception in your AJUI Button instance that will replace the current value (Default) when the state that is linked to it is triggered.

Example of assigning a color to the text of the button for each state :

$Mybtn.FontColor(AJUI_btn_default;"lightblue")
$Mybtn.FontColor(AJUI_btn_hover;"blue")
$Mybtn.FontColor(AJUI_btn_active;"darkblue")
$Mybtn.FontColor(AJUI_btn_disable;"grey")
$Mybtn.FontColor(AJUI_btn_focus;"red")