Labels play a crucial role in app interfaces, providing descriptive text to guide users and convey important information. They are used to identify and describe various elements such as buttons, text fields, and images, ensuring that users understand their purpose and how to interact with them. Labels are customizable, allowing developers to tailor them to the app´s design and user experience needs. By effectively using labels, developers can enhance the usability and accessibility of their apps, making them more intuitive and user-friendly.
In the upcoming video, you´ll discover how to configure two labels by positioning them, altering their colors, and setting an initial text.
After positioning the labels, we proceed to create two buttons and program them to change the text of the labels when clicked.
Next, we create two more buttons to retrieve the content of the labels.
During runtime, you can use the _Text() command to set text for a label. To retrieve the value from a label, you can use the _Get_Text() command.
Code Copied to the Clipboard
These functions demonstrate how to interact with labels in Kenzie. Each function is triggered by a button press event (''onRelease'') and performs a specific action:
- button_change_title_onRelease: This function sets the text of a label named ''label_titulo'' to ''New Title'' when the corresponding button is pressed.
- button_change_subtitle_onRelease: Similarly, this function sets the text of a label named ''label_subtitle'' to ''This New SubTitle'' when its associated button is pressed.
- button_get_subtitle_onRelease: When this button is pressed, it displays a message box containing the text currently set in the ''label_subtitle'' label. The _Get_Text() function retrieves the text from the label.
- button_get_title_onRelease: Similarly, this function retrieves the text from the ''label_titulo'' label and displays it in a message box when the corresponding button is pressed.
These functions demonstrate basic interactions with labels, including setting text and retrieving text values for further use or display.
In the video, you can observe the example in action. Initially, you´ll see the original values set in the Designer area. Then, you´ll witness the dynamic alteration of label values during runtime using the _Text() command. Finally, you´ll see the retrieval of the updated values using _Get_Text().
You can download the project from the following link:
Class_Rar_0__23.rar
Label Properties
During design mode, you can assign the following properties and events to a Label:

Here is the list of properties and their usage for Labels:
- name: The name of the label.
- Content
- text: The text content of the label.
- Position and Size
- x: The x-coordinate position of the label.
- y: The y-coordinate position of the label.
- const_anchorX: The x-anchor point of the label.
- const_anchorY: The y-anchor point of the label.
- width: The width of the label.
- height: The height of the label.
- toBack: Set to true to move the label to the back layer.
- toFront: Set to true to move the label to the front layer.
- Appearance
- align: The alignment of the text within the label (center, left, right).
- font: The font style of the text.
- fontsize: The font size of the text.
- foreColor_RGB: The RGB color of the text foreground.
- foreColorAlpha: The alpha transparency of the text foreground.
- backColor_RGB: The RGB color of the label background.
- backAlpha: The alpha transparency of the label background.
- borderColor_RGB: The RGB color of the label border.
- borderAlpha: The alpha transparency of the label border.
- borderWidth: The width of the label border.
- isVisible: Set to true to make the label visible.
- isborderVisible: Set to true to make the label border visible.
- isbackColorVisible: Set to true to make the label background color visible.
- labelText_Y_Offset: The vertical offset of the text within the label.
- Functions
- touch: The function to execute when the label is touched.
- release: The function to execute when the label is released after being touched.
|