This repository has been archived by the owner on Dec 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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 )
Adds a button to the application user interface.
- Page (
int
) : The number of the page which contains the new button - X (
unsigned int
) : The X position of the new button in pixels. You can use CENTER or RIGHT too. - Y (
unsigned int
) : The Y position of the new button in pixels - Width (
unsigned int
) : The width of the new button in pixels - Height (
unsigned int
) : The height of the new button in pixels - text (
String
) : Text to show inside the button - textcolor (
unsigned int
) optional: A 16-bit number representing the text (foreground) color of the button. Default: white (TFT_WHITE
) - backcolor (
unsigned int
) optional: A 16-bit number representing the background color of the button. Default: dark grey (TFT_DARKGREY
) - 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. - enabled (
bool
) optional: If false, the button is darkened and cannot be clicked. Default:true
- visible (
unsigned int
) optional: Iffalse
, the button is hidden (not shown). Default:true
- radius (
int
) optional: The border radius of the button in pixels. You can useCIRCLE
for maximum possible radius. Default: 0 pixels - 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 - YtextOffset (
int
) optional advanced: Same as above but affects Y position. Default: 0
The index of the new button
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)