3. Circle Button Creation in Nextion: A Comprehensive Guide

3. Circle Button Creation in Nextion: A Comprehensive Guide

Nextion is a robust graphical consumer interface (GUI) growth platform for embedded methods. It permits builders to simply create customized GUIs for his or her gadgets with out the necessity for intensive coding. One of the vital widespread GUI components is the button. Buttons can be utilized to set off actions, navigate between screens, and extra. On this article, we are going to present you find out how to make a button right into a circle utilizing Nextion.

To make a button right into a circle, you will have to make use of the “circle” property. The “circle” property might be set to “true” or “false”. When the “circle” property is ready to “true”, the button can be drawn as a circle. You can too specify the radius of the circle utilizing the “radius” property. The “radius” property is measured in pixels.

Furthermore, you’ll be able to customise the looks of the button by setting the “background shade,” “textual content shade,” and “font” properties. The “background shade” property specifies the colour of the button’s background. The “textual content shade” 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 vary a button’s form to a circle, open the Nextion Editor and choose the button you need to edit. Within the “Properties” panel, you may discover the “Form” property. Click on on the drop-down menu and choose “Circle”.

Alternatively, you should utilize the next code to alter the button’s form:

“`
btn.form = “circle”
“`

Customizing the Circle Button

As soon as you’ve got modified the button’s form to a circle, you’ll be able to 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 find out how 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 entails 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 sort. Then, underneath “Type”, select “RoundRect” to create a circle-shaped button.

2. Regulate 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 Colour and Border

Use the “BKG Colour” and “Border Colour” properties to specify the fill shade and description shade of the circle button, respectively.

4. Setting Superior Look Choices

The “Superior” part provides further 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 total 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 here 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, akin 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 standard selection for creating consumer interfaces for embedded methods, akin to these present in industrial equipment, medical gadgets, and shopper electronics. One of the vital widespread components utilized in Nextion GUIs is the button. By default, buttons are rectangular, however it’s doable to create round buttons.

To create a round button in Nextion, you will have to make use of the “ImageButton” object. The ImageButton object permits you to specify a picture file for use because the button’s background. You may then use the “Form” property to specify that the button must be round.

Listed here are the steps on find out how to create a round button in Nextion:

  1. Open the Nextion Editor and create a brand new undertaking.
  2. Choose the “ImageButton” object from the Toolbox.
  3. Drag and drop the ImageButton object onto the Kind.
  4. Within the Properties window, set the next properties:
    • Identify: The title 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.
  5. Click on the “OK” button to save lots of the modifications.

Individuals Additionally Ask About Nextion How To Make A Button Into A Circle

Can I exploit any picture file because the button’s background?

Sure, you should utilize any picture file because the button’s background. Nevertheless, the picture file should be in a supported format, akin to BMP, JPG, or PNG.

Can I alter the dimensions and place of the button?

Sure, you’ll be able to 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 utilize the “Textual content” property. The Textual content property permits you to specify the textual content that can be displayed on the button.