Skip to content

Class Functions

Gabriel Inzirillo edited this page Oct 14, 2022 · 7 revisions

In this chapter, we will cover the class functions available. Every function acts as a getter or a setter.

It is not recommended to modify the object directly. You must use the class functions.

Button state

Many function require a first parameter which is the button state. This is to know for which button state you would like to change a property. Some constants are given with the component :

  • AJUI_btn_default : "default"
  • AJUI_btn_hover : "hover"
  • AJUI_btn_active : "active"
  • AJUI_btn_disable : "disable"
  • AJUI_btn_focus : "focus"

For example, if you want to change the background color for the on hover state, you must use the AJUI_btn_hover constant as the first parameter

Form.btn.backgroundColor(AJUI_btn_hover;"green")

⚠️ When using a getter with a function that require the state of the button, this first parameter is mandatory in order to know for which state you would like to get the value.

Colors

Colors can be used as defined here SVG Colors.

Index

Global

Button Box

Text

Picture

Composite

FAB (Floating Action Button)


name

Description

Name of the button. Must be the name of the form variable widget where you want to bind the button.

Parameter(s)

(text) name

Example

Form.btn.name("btn")

Back to Top


type

Description

Type of button. Only 2 types are possible :

  • rectangle
  • circle

Parameter(s)

(text) type

Default value

"rectangle"

Example

Form.btn.type("circle")

Back to Top


composition

Description

Button composition :

  • text
  • picture
  • composite

Parameter(s)

(text) button composition

Default value

"text"

Example

Form.btn.composition("composite")

Back to Top


onClick

Description

Callback of the on click event. Can be a formula or a method name. You can pass an object as a parameter to this callback

Parameter(s)

(variant) method name or a formula (object) parameters

Example

Form.btn.onClick("btn_onClick")
Form.btn.onClick(Formula(on_click))
Form.btn.onClick(Formula(ALERT($1.message));New object("message";"hello world"))

Back to Top


onDoubleClick

Description

Callback of the on double click event. Can be a formula or a method name. You can pass an object as a parameter to this callback

Parameter(s)

(variant) method name or a formula (object) parameters

Example

Form.btn.onDoubleClick("btn_onClick")
Form.btn.onDoubleClick(Formula(on_click))
Form.btn.onDoubleClick(Formula(ALERT($1.message));New object("message";"hello world"))

Back to Top


draw

Description

Draw the button. It will handle the event for the different states.

Example

Form.btn.draw()

Back to Top


enable

Description

Enable or disable the button.

Parameter(s)

(boolean) True/False

Example

Form.btn.enable(True)

Back to Top


hide

Description

Hide the button

Example

Form.btn.hide()

Back to Top


show

Description

Show the button

Example

Form.btn.show()

Back to Top


removePropertyException

Description

Remove a property exception for a specific state. For example you can remove the borderColor for the onHover state.

Parameter(s)

(text) property to remove (text) button state

Example

Form.btn.removePropertyException("borderColor";AJUI_Btn_hover)

Back to Top


removePropertyExceptions

Description

Remove a property exception for all the states.

Parameter(s)

(text) property to remove

Example

Form.btn.removePropertyExceptions("borderColor")

Back to Top


resetState

Description

Remove all the properties for a specific state. For example you can reset the onHover state to the default.

Parameter(s)

(text) button state

Example

Form.btn.resetState(AJUI_Btn_hover)

Back to Top


resetAllStates

Description

Remove all the properties for all the states.

Example

Form.btn.resetAllStates()

Back to Top


backgroundColor

Alias

bgColor

Description

Background color of the button

Parameter(s)

(text) button state (text) color

Default value

"#4d9ad4"

Example

Form.btn.backgroundColor(AJUI_btn_hover;"green")
Form.btn.bgColor(AJUI_btn_hover;"#fcc728")

Back to Top


cornerRadius

Description

Corner radius of the button's corners.

Parameter(s)

(text) button state (longint) radius

Default value

5

Example

Form.btn.cornerRadius(AJUI_btn_hover;5)

Back to Top


height

Description

Height of the button. If set, this value will only be used if the resizable is set to true. If resizable is set to true and the value of heightis -1 the size will be the one defined in the form variable widget.

Parameter(s)

(text) button state (longint) height

Default value

-1

Example

Form.btn.height(AJUI_btn_default;13)

Back to Top


width

Description

Width of the button. If set, this value will only be used if the resizable is set to true. If resizable is set to true and the value of widthis -1 the size will be the one defined in the form variable widget.

Parameter(s)

(text) button state (longint) width

Default value

-1

Example

Form.btn.width(AJUI_btn_default;120)

Back to Top


resizable

Description

Boolean value that says if we want to resize the form variable widget or not.

Parameter(s)

(boolean) resizable

Default value

False

Example

Form.btn.resizable(True)

Back to Top


padding

Description

Set the padding of the button, cannot be <0.

Parameter(s)

(text) button state (longint) padding

Default value

3

Example

Form.btn.padding(AJUI_btn_default;10)

Back to Top


borderSize

Description

Border size.

Parameter(s)

(text) button state (longint) size

Default value

0

Example

Form.btn.borderSize(AJUI_btn_default;2)

Back to Top


borderColor

Description

Border color.

Parameter(s)

(text) button state (text) color

Default value

"#0a509e"

Example

Form.btn.borderColor(AJUI_btn_default;"blue")

Back to Top


label

Description

Label of the button to be displayed.

Parameter(s)

(text) button state (text) label

Default value

Label

Example

Form.btn.label(AJUI_btn_default;"Click Me!")

Back to Top


fontSize

Description

Font size.

Parameter(s)

(text) button state (longint) size

Default value

16

Example

Form.btn.fontSize(AJUI_btn_default;12)

Back to Top


fontColor

Description

Font color.

Parameter(s)

(text) button state (text) color

Default value

"white"

Example

Form.btn.fontColor(AJUI_btn_default;"lightblue")

Back to Top


fontName

Description

Font name.

Parameter(s)

(text) button state (text) font name(s). Can be different fonts separated by a comma.

Default value

"Arial, Helvetica, MS Sans Serif"

Example

Form.btn.fontName(AJUI_btn_default;"Times")

Back to Top


fontStyle

Description

Font style.

Parameter(s)

(text) button state (text) font style(s). Any of those, separated by a , :

  • Bold
  • Italic
  • Underline
  • Strikethrough

Example

Form.btn.fontStyle(AJUI_btn_default;"Bold")

Back to Top


textAlign

Description

Alignment of the text.

Parameter(s)

(text) button state (text) text Align :

  • left
  • center
  • right

Default value

"center"

Example

Form.btn.textAlign(AJUI_btn_default;"left")

Back to Top


horizontalMargin

Description

Horizontal margin. Left and right margin of the text.

Parameter(s)

(text) button state (longint) horizontal margin

Default value

0

Example

Form.btn.horizontalMargin(AJUI_btn_default;10)

Back to Top


picturePath

Description

Path to the picture to display relative to the Resources folder.

You can also use "#" as the root of your picture path. This will only work with an imported AJUI Button template and the picture must be located in the same folder as the template.

Parameter(s)

(text) button state (text) picture path

Example

Form.btn.picturePath(AJUI_btn_default;"images/icons/add.svg")

Back to Top


pictureHeight

Description

Height of the picture.

Parameter(s)

(text) button state (longint) picture height. -1 takes the original height of the picture

Default value

-1

Example

Form.btn.pictureHeight(AJUI_btn_default;24)

Back to Top


pictureWidth

Description

Width of the picture.

Parameter(s)

(text) button state (longint) picture width. -1 takes the original width of the picture

Default value

-1

Example

Form.btn.pictureWidth(AJUI_btn_default;24)

Back to Top


colorToReplace

Description

When using svg as a picture, you can define a color that will be replacing during runtime. For example, you want an icon to change the color on hover. Correspond to the svg fill and/or stroke attributes.

Parameter(s)

(text) color to replace

Example

Form.btn.colorToReplace("black")

Back to Top


replacingColor

Description

Color that will replace the one set with the colorToReplace function.

Parameter(s)

(text) button state (text) color

Example

Form.btn.replacingColor(AJUI_btn_hover;"blue")

Back to Top


pictureOpacity

Description

Opacity of the picture.

Parameter(s)

(text) button state (longint) opacity (0-100)

Default value

100

Example

Form.btn.pictureOpactiy(AJUI_btn_default;50)

Back to Top


pictureRatio

Description

Ratio of the picture.

Parameter(s)

(text) button state (longint) ratio (0-1)

Default value

1

Example

Form.btn.pictureRatio(AJUI_btn_default;0.5)

Back to Top


pictureScale

Description

Scale of the picture related to the button size.

Parameter(s)

(text) button state (longint) scale (0-100). 0 means no scale.

Default value

0

Example

Form.btn.pictureScale(AJUI_btn_default;50)

Back to Top


picturePosition

Description

Picture position. Only for composite button.

Parameter(s)

(text) button state (text) position. Available position :

  • left
  • right
  • top
  • bottom

Default value

"left"

Example

Form.btn.picturePosition(AJUI_btn_default;"right")

Back to Top


pictureAllocation

Description

Picture allocation when the composition is composite. Percentage of the size opf the button allocated to the picture. Only for composite button.

Parameter(s)

(text) button state (longint) allocation (0-100)

Default value

30

Example

Form.btn.pictureAllocation(AJUI_btn_default;50)

Back to Top


activateSecondaryColor

Description

Activate or not the secondary color. Only for compositeand when the picture is not linked to the text.

Parameter(s)

(boolean) activated

Default value

True

Example

Form.btn.activateSecondaryColor(False)

Back to Top


backgroundSecondaryColor

Alias

bgSecondaryColor

Description

Background color of the picture if activated. Only for composite button.

Parameter(s)

(text) button state (text) background color

Default value

"#9fddf9"

Example

Form.btn.backgroundSecondaryColor(AJUI_btn_default;"yellow")
Form.btn.bgSecondaryColor(AJUI_btn_default;"orange")

Back to Top


linkTextToPicture

Description

Link the text and the picture. Only for composite button.

Parameter(s)

(boolean) link

Default value

False

Example

Form.btn.linkTextToPicture(True)

Back to Top


spaceBetween

Description

Space between a linked text and picture. Only for composite button.

Parameter(s)

(text) button state (longint) space

Default value

10

Example

Form.btn.spaceBetween(AJUI_Btn_default;5)

Back to Top


FAB_main

Description

Define the button as the main FAB button. When defined, the click will alternatively show and hide all the FAB button associated with the FAB_add function. Any callbacks defined (OnClick and OnDoubleClick) to this button will be ignored.

Parameter(s)

(boolean) True/False

Default value

False

Example

Form.btn.FAB_main(True)

Back to Top


FAB_add

Description

Add a button in the list to be displayed when the main button is clicked.

Parameter(s)

(text) button name (longint) (optional) position

Example

Form.btn.FAB_add("add_btn")
Form.btn.FAB_add("delete_btn")
Form.btn.FAB_add("edit_btn";2)

Back to Top


FAB_position

Description

Define the position of the main button :

  • top-left
  • top (top-center)
  • top-right
  • left (left-center)
  • center
  • right (right-center)
  • bottom-left
  • bottom (bottom-center)
  • bottom-right

It will update the value for angle and startAngle.

Parameter(s)

(text) position

Example

Form.btn.FAB_position("center")

Back to Top


FAB_angle

Description

Define the angle (in degrees) where the buttons will be displayed.

Parameter(s)

(longint) angle

Example

Form.btn.FAB_angle(90)

Back to Top


FAB_startAngle

Description

Define the angle (in degrees) where the buttons will start to be displayed.

Parameter(s)

(longint) angle

Example

Form.btn.FAB_startAngle(180)

Back to Top


FAB_radius

Description

Radius between the main button and the displayed buttons.

Parameter(s)

(longint) radius

Example

Form.btn.FAB_radius(80)

Back to Top


FAB_clockwise

Description

Define the direction to display the fab buttons.

Parameter(s)

(boolean) True/False

Example

Form.btn.FAB_clockwise(False)

Back to Top


FAB_animated

Description

Animate the button upon display.

Parameter(s)

(boolean) True/False

Example

Form.btn.FAB_animated(True)

Back to Top


FAB_remove

Description

Remove a button.

Parameter(s)

(text) button name

Example

Form.btn.FAB_remove("delete_btn")

Back to Top


FAB_clearCollection

Description

Remove all the buttons.

Example

Form.btn.FAB_clearCollection()

Back to Top


Clone this wiki locally