2021-04-12 18:19:04 +02:00
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/widgets/btn.md
```
# Button (lv_btn)
## Overview
2021-06-09 15:10:35 +02:00
Buttons have no new features compared to the [Base object ](/widgets/obj ). They are usuful for semantic purposes and have slightly different default settings.
2021-04-12 18:19:04 +02:00
2021-06-09 15:10:35 +02:00
Buttons, by default, differ from Base object in the following ways:
2021-04-30 20:33:11 +02:00
- Not scrollable
- Added to the default group
2021-06-09 15:10:35 +02:00
- Default height and width set to `LV_SIZE_CONTENT`
2021-04-12 18:19:04 +02:00
## Parts and Styles
2021-06-09 15:10:35 +02:00
- `LV_PART_MAIN` The background of the button. Uses the typical background style properties.
2021-04-12 18:19:04 +02:00
## Usage
2021-04-30 20:33:11 +02:00
There are no new features compared to [Base object ](/widgets/obj ).
2021-04-12 18:19:04 +02:00
## Events
2021-06-09 15:10:35 +02:00
- `LV_EVENT_VALUE_CHANGED` when the `LV_OBJ_FLAG_CHECKABLE` flag is enabled and the object is clicked. The event happens on transition to/from the checked state.
2021-04-30 20:33:11 +02:00
2021-04-12 18:19:04 +02:00
Learn more about [Events ](/overview/event ).
## Keys
2021-06-09 15:10:35 +02:00
If `LV_OBJ_FLAG_CHECKABLE` is enabled `LV_KEY_RIGHT` and `LV_KEY_UP` make the object checked, and `LV_KEY_LEFT` and `LV_KEY_DOWN` make it unchecked.
2021-04-12 18:19:04 +02:00
2021-06-09 15:10:35 +02:00
Note that the state of `LV_KEY_ENTER` is translated to `LV_EVENT_PRESSED/PRESSING/RELEASED` etc.
2021-04-12 18:19:04 +02:00
Learn more about [Keys ](/overview/indev ).
## Example
```eval_rst
2021-05-03 17:32:57 +02:00
.. include:: ../../../examples/widgets/btn/index.rst
2021-04-12 18:19:04 +02:00
```
## API
```eval_rst
.. doxygenfile:: lv_btn.h
:project: lvgl
```