acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
checkbox.md (2484B)
1 ```eval_rst 2 .. include:: /header.rst 3 :github_url: |github_link_base|/widgets/core/checkbox.md 4 ``` 5 # Checkbox (lv_checkbox) 6 7 8 ## Overview 9 10 The Checkbox object is created from a "tick box" and a label. When the Checkbox is clicked the tick box is toggled. 11 12 ## Parts and Styles 13 - `LV_PART_MAIN` The is the background of the Checkbox and it uses the text and all the typical background style properties. 14 `pad_column` adjusts the spacing between the tickbox and the label 15 - `LV_PART_INDICATOR` The "tick box" is a square that uses all the typical background style properties. 16 By default, its size is equal to the height of the main part's font. Padding properties make the tick box larger in the respective directions. 17 18 The Checkbox is added to the default group (if it is set). 19 20 ## Usage 21 22 23 ### Text 24 The text can be modified with the `lv_checkbox_set_text(cb, "New text")` function and will be dynamically allocated. 25 26 To set a static text, 27 use `lv_checkbox_set_static_text(cb, txt)`. This way, only a pointer to `txt` will be stored. The text then shouldn't be deallocated while the checkbox exists. 28 29 ### Check, uncheck, disable 30 You can manually check, un-check, and disable the Checkbox by using the common state add/clear function: 31 ```c 32 lv_obj_add_state(cb, LV_STATE_CHECKED); /*Make the chekbox checked*/ 33 lv_obj_clear_state(cb, LV_STATE_CHECKED); /*MAke the checkbox unchecked*/ 34 lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED); /*Make the checkbox checked and disabled*/ 35 ``` 36 37 ## Events 38 - `LV_EVENT_VALUE_CHANGED` Sent when the checkbox is toggled. 39 - `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END` are sent for the following types: 40 - `LV_CHECKBOX_DRAW_PART_BOX` The tickbox of the checkbox 41 - `part`: `LV_PART_INDICATOR` 42 - `draw_area`: the area of the tickbox 43 - `rect_dsc` 44 45 See the events of the [Base object](/widgets/obj) too. 46 47 Learn more about [Events](/overview/event). 48 49 50 ## Keys 51 The following *Keys* are processed by the 'Buttons': 52 - `LV_KEY_RIGHT/UP` Go to toggled state if toggling is enabled 53 - `LV_KEY_LEFT/DOWN` Go to non-toggled state if toggling is enabled 54 - `LV_KEY_ENTER` Clicks the checkbox and toggles it 55 56 Note that, as usual, the state of `LV_KEY_ENTER` is translated to `LV_EVENT_PRESSED/PRESSING/RELEASED` etc. 57 58 Learn more about [Keys](/overview/indev). 59 60 61 ## Example 62 63 ```eval_rst 64 65 .. include:: ../../../examples/widgets/checkbox/index.rst 66 67 ``` 68 69 ## API 70 71 ```eval_rst 72 73 .. doxygenfile:: lv_checkbox.h 74 :project: lvgl 75 76 ```