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 |
imgbtn.md (2052B)
1 ```eval_rst 2 .. include:: /header.rst 3 :github_url: |github_link_base|/widgets/extra/imgbtn.md 4 ``` 5 # Image button (lv_imgbtn) 6 7 ## Overview 8 9 The Image button is very similar to the simple 'Button' object. The only difference is that it displays user-defined images in each state instead of drawing a rectangle. 10 11 You can set a left, right and center image, and the center image will be repeated to match the width of the object. 12 13 14 15 ## Parts and Styles 16 - `LV_PART_MAIN` Refers to the image(s). If background style properties are used, a rectangle will be drawn behind the image button. 17 18 ## Usage 19 20 ### Image sources 21 To set the image in a state, use the `lv_imgbtn_set_src(imgbtn, LV_IMGBTN_STATE_..., src_left, src_center, src_right)`. 22 23 The image sources work the same as described in the [Image object](/widgets/core/img) except that "Symbols" are not supported by the Image button. 24 Any of the sources can `NULL`. 25 26 The possible states are: 27 - `LV_IMGBTN_STATE_RELEASED` 28 - `LV_IMGBTN_STATE_PRESSED` 29 - `LV_IMGBTN_STATE_DISABLED` 30 - `LV_IMGBTN_STATE_CHECKED_RELEASED` 31 - `LV_IMGBTN_STATE_CHECKED_PRESSED` 32 - `LV_IMGBTN_STATE_CHECKED_DISABLED` 33 34 If you set sources only in `LV_IMGBTN_STATE_RELEASED`, these sources will be used in other states too. 35 If you set e.g. `LV_IMGBTN_STATE_PRESSED` they will be used in pressed state instead of the released images. 36 37 38 ### States 39 Instead of the regular `lv_obj_add/clear_state()` functions the `lv_imgbtn_set_state(imgbtn, LV_IMGBTN_STATE_...)` functions should be used to manually set a state. 40 41 42 ## Events 43 - `LV_EVENT_VALUE_CHANGED` Sent when the button is toggled. 44 45 Learn more about [Events](/overview/event). 46 47 ## Keys 48 - `LV_KEY_RIGHT/UP` Go to toggled state if `LV_OBJ_FLAG_CHECKABLE` is enabled. 49 - `LV_KEY_LEFT/DOWN` Go to non-toggled state if `LV_OBJ_FLAG_CHECKABLE` is enabled. 50 - `LV_KEY_ENTER` Clicks the button 51 52 53 Learn more about [Keys](/overview/indev). 54 55 ## Example 56 57 ```eval_rst 58 59 .. include:: ../../../examples/widgets/imgbtn/index.rst 60 61 ``` 62 63 ## API 64 65 ```eval_rst 66 67 .. doxygenfile:: lv_imgbtn.h 68 :project: lvgl 69 70 ```