Button Element btn

btn(id, r, action)
  • id (optional): element ID
  • r (required): the rectangle where the button will be displayed, type is Rect.
  • action (optional): the click behavior of the button, see datatype for possible values

After an element is defined, its id attribute, in addition to the Rect variable representing the drawing range of the element, also has the following attributes:

  • id.pressing: whether the button is being pressed, 1 if pressed, 0 otherwise
  • id.last: the last time the button was pressed. If it has never been pressed, the value is -1.
  • id.count: the number of times the button has been pressed