Skip to content
This repository has been archived by the owner on Dec 20, 2021. It is now read-only.

addbutton()

Mammad900 edited this page Aug 28, 2020 · 3 revisions

addbutton(page, X, Y, Width, Height, text, textcolor, backcolor, bordercolor, enabled, visible, radius, XtextOffset, YtextOffset )

Summary

Adds a button to the application user interface.

Parameters

  1. Page (int) : The number of the page which contains the new button
  2. X (unsigned int) : The X position of the new button in pixels. You can use CENTER or RIGHT too.
  3. Y (unsigned int) : The Y position of the new button in pixels
  4. Width (unsigned int) : The width of the new button in pixels
  5. Height (unsigned int) : The height of the new button in pixels
  6. text (String) : Text to show inside the button
  7. textcolor (unsigned int) optional: A 16-bit number representing the text (foreground) color of the button. Default: white (TFT_WHITE)
  8. backcolor (unsigned int) optional: A 16-bit number representing the background color of the button. Default: dark grey (TFT_DARKGREY)
  9. bordercolor (unsigned int) optional: A 16-bit number representing the border color of the button. Default: If neither text color nor background color were passed, it's light gray (TFT_LIGHTGREY). Else, it's the same as background color.
  10. enabled (bool) optional: If false, the button is darkened and cannot be clicked. Default: true
  11. visible (unsigned int) optional: If false, the button is hidden (not shown). Default: true
  12. radius (int) optional: The border radius of the button in pixels. You can use CIRCLE for maximum possible radius. Default: 0 pixels
  13. XtextOffset (int) optional advanced: Use this if some pixels of text appear outside the button. For example passing 1 means it is moved 1 pixel to right. Default: 0
  14. YtextOffset (int) optional advanced: Same as above but affects Y position. Default: 0

Returns

The index of the new button

Examples

addbutton(PAGE_MAIN,0,0,50,60,"Hello"); // Create a button with default colors (dark gray background, light gray border, white text) at top left with 50px width and 60px height, with 'Hello' shown inside it
addbutton(PAGE_MAIN,CENTER,0,100,60,"A",TFT_BLACK,TFT_CYAN,TFT_BLUE); // Create a button with cyan background, blue border and black text at top center with 100px width and 60px height, with 'A' shown inside it
addbutton(PAGE_MAIN,CENTER,0,100,60,"A",TFT_BLACK,TFT_CYAN,TFT_BLUE,false,true,CIRCLE); // Create a rounded *disabled* button with cyan background, blue border and black text at top center with 100px width and 60px height, with 'A' shown inside it
addbutton(PAGE_MAIN,CENTER,0,100,60,"A",TFT_BLACK,TFT_CYAN,TFT_BLUE,true,false); // Create a *hidden* button with cyan background, blue border and black text at top center with 100px width and 60px height, with 'A' shown inside it
addbutton(PAGE_MAIN,CENTER,0,100,60,"A",TFT_BLACK,TFT_CYAN,TFT_BLUE,true,true,0,0,-10); // Create a hidden button with cyan background, blue border and black text at top center with 100px width and 60px height, with 'A' shown inside it (but 10 pixels higher than usual)
Clone this wiki locally