Nextion is a strong graphical consumer interface (GUI) growth platform for embedded techniques. It permits builders to simply create customized GUIs for his or her units with out the necessity for intensive coding. Some of the widespread GUI parts is the button. Buttons can be utilized to set off actions, navigate between screens, and extra. On this article, we’ll present you methods to make a button right into a circle utilizing Nextion.
To make a button right into a circle, you will want to make use of the “circle” property. The “circle” property will be set to “true” or “false”. When the “circle” property is about to “true”, the button might be drawn as a circle. You may as well specify the radius of the circle utilizing the “radius” property. The “radius” property is measured in pixels.
Furthermore, you may customise the looks of the button by setting the “background colour,” “textual content colour,” and “font” properties. The “background colour” property specifies the colour of the button’s background. The “textual content colour” property specifies the colour of the button’s textual content. The “font” property specifies the font of the button’s textual content.
Altering the Button’s Form to Circle
To alter a button’s form to a circle, open the Nextion Editor and choose the button you need to edit. Within the “Properties” panel, you will discover the “Form” property. Click on on the drop-down menu and choose “Circle”.
Alternatively, you should use the next code to alter the button’s form:
“`
btn.form = “circle”
“`
Customizing the Circle Button
As soon as you have modified the button’s form to a circle, you may additional customise its look by adjusting the next properties:
| Property | Description |
|---|---|
| radius | The radius of the circle button in pixels. |
| borderWidth | The width of the button’s border in pixels. |
| borderColor | The colour of the button’s border. |
| fillColor | The colour of the button’s inside. |
| picture | The trail to a picture file to be displayed on the button. |
| imagePos | The place of the picture on the button. |
Instance
The next code demonstrates methods to create a customized circle button:
“`
btn.form = “circle”
btn.radius = 50
btn.borderWidth = 2
btn.borderColor = “#FF0000”
btn.fillColor = “#00FF00”
btn.picture = “button.png”
btn.imagePos = “heart”
“`
This code will create a round button with a purple border, a inexperienced inside, a radius of fifty pixels, and a centered picture.
Configuring the Circle Button’s Look
Customizing the circle button’s visible attributes includes setting particular parameters within the Nextion Editor’s object properties panel. The next steps information you thru the configuration course of:
1. Set Button Sort to “RoundRect”
Within the “Object” part, choose “Button” as the thing kind. Then, underneath “Fashion”, select “RoundRect” to create a circle-shaped button.
2. Alter Nook Radius
The “Nook Radius” property determines the curvature of the circle’s corners. Set this worth to “0” for an ideal circle.
3. Configure Background Shade and Border
Use the “BKG Shade” and “Border Shade” properties to specify the fill colour and description colour of the circle button, respectively.
4. Setting Superior Look Choices
The “Superior” part presents extra customization choices for the circle button:
| Property | Description |
|---|---|
| Gradient | Provides a gradient impact to the button’s background |
| Picture | Inserts a picture throughout the button’s boundaries |
| Align/Scale | Controls the place and dimension of the picture throughout the button |
| Alpha Transparency | Adjusts the transparency of the button’s general look |
Occasion Dealing with for the Circle Button
The circle button helps a variety of occasion dealing with choices, permitting you to customise its conduct in response to consumer actions. Listed below are the commonest occasion handlers used with the circle button:
onTap(occasion)
The `onTap` occasion handler is triggered when the consumer faucets on the circle button. This occasion can be utilized to execute a selected motion or operate when the button is clicked.
So as to add an `onTap` occasion handler to the circle button, use the next syntax:
“`
my_circle_button.onTap(operate() {
// Code to execute when the button is clicked
});
“`
onTouchStart(occasion) and onTouchEnd(occasion)
The `onTouchStart` and `onTouchEnd` occasion handlers are triggered when the consumer touches and releases the circle button, respectively. These occasions can be utilized to carry out completely different actions primarily based on the consumer’s contact gesture.
So as to add `onTouchStart` and `onTouchEnd` occasion handlers to the circle button, use the next syntax:
“`
my_circle_button.onTouchStart(operate() {
// Code to execute when the button is touched
});
my_circle_button.onTouchEnd(operate() {
// Code to execute when the button is launched
});
<h4><ins>onHold(period)</ins></h4>
<p>The `onHold` occasion handler is triggered when the consumer holds the circle button for a specified period. This occasion can be utilized to carry out actions that require a sustained press, equivalent to opening a context menu.</p>
<p>So as to add an `onHold` occasion handler to the circle button, use the next syntax:</p>
my_circle_button.onHold(500, operate() {
// Code to execute when the button is held for 500ms
});
Nextion How To Make A Button Into A Circle
Nextion is a graphical consumer interface (GUI) for human-machine interfaces (HMIs). It’s a widespread alternative for creating consumer interfaces for embedded techniques, equivalent to these present in industrial equipment, medical units, and shopper electronics. Some of the widespread parts utilized in Nextion GUIs is the button. By default, buttons are rectangular, however it’s potential to create round buttons.
To create a round button in Nextion, you will want to make use of the “ImageButton” object. The ImageButton object means that you can specify a picture file for use because the button’s background. You may then use the “Form” property to specify that the button ought to be round.
Listed below are the steps on methods to create a round button in Nextion:
- Open the Nextion Editor and create a brand new mission.
- Choose the “ImageButton” object from the Toolbox.
- Drag and drop the ImageButton object onto the Kind.
- Within the Properties window, set the next properties:
- Title: The identify of the button.
- Picture: The picture file for use because the button’s background.
- Form: Circle.
- Dimension: The dimensions of the button.
- Place: The place of the button.
- Click on the “OK” button to save lots of the adjustments.
Folks Additionally Ask About Nextion How To Make A Button Into A Circle
Can I take advantage of any picture file because the button’s background?
Sure, you should use any picture file because the button’s background. Nevertheless, the picture file should be in a supported format, equivalent to BMP, JPG, or PNG.
Can I modify the dimensions and place of the button?
Sure, you may change the dimensions and place of the button. To do that, merely choose the button after which use the Properties window to regulate the Dimension and Place properties.
How do I add textual content to the button?
So as to add textual content to the button, you should use the “Textual content” property. The Textual content property means that you can specify the textual content that might be displayed on the button.