App:Library:LVGL:docs:Widgets:Checkbox (lv checkbox)

提供: robot-jp wiki
ナビゲーションに移動検索に移動

https://docs.lvgl.io/8.2/widgets/core/arc.html

Checkbox (lv_checkbox)

Overview

英文 自動翻訳

The Checkbox object is created from a "tick box" and a label. When the Checkbox is clicked the tick box is toggled.

チェックボックスオブジェクトは、「チェックボックス」とラベルから作成されます。チェックボックスをクリックすると、チェックボックスが切り替わります。
戻る : Previous


Parts and Styles

英文 自動翻訳
  • LV_PART_MAIN The is the background of the Checkbox and it uses the text and all the typical background style properties. pad_column adjusts the spacing between the tickbox and the label
  • LV_PART_INDICATOR The "tick box" is a square that uses all the typical background style properties. 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.

The Checkbox is added to the default group (if it is set).

  • LV_PART_MAINこれはチェックボックスの背景であり、テキストとすべての一般的な背景スタイルのプロパティを使用します。pad_columnチェックボックスとラベルの間の間隔を調整します
  • LV_PART_INDICATOR「チェックボックス」は、すべての一般的な背景スタイルのプロパティを使用する正方形です。デフォルトでは、そのサイズは主要部分のフォントの高さと同じです。パディングプロパティにより、チェックボックスがそれぞれの方向に大きくなります。

チェックボックスがデフォルトグループに追加されます(設定されている場合)。

戻る : Previous


Usage

Text

英文 自動翻訳

The text can be modified with the lv_checkbox_set_text(cb, "New text") function and will be dynamically allocated.

To set a static text, 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.

テキストはlv_checkbox_set_text(cb, "New text")関数で変更可能で、動的に確保されます。

静的なテキストを設定するには、lv_checkbox_set_static_text(cb, txt)を使用します。この方法では、txtへのポインタのみが格納されます。この場合、チェックボックスが存在する間は、テキストは割り当て解除されないはずです。

戻る : Previous


Check, uncheck, disable

英文 自動翻訳

You can manually check, un-check, and disable the Checkbox by using the common state add/clear function:

 lv_obj_add_state(cb, LV_STATE_CHECKED);   /*Make the chekbox checked*/
 lv_obj_clear_state(cb, LV_STATE_CHECKED); /*MAke the checkbox unchecked*/
 lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED); /*Make the checkbox checked and disabled*/

共通状態の追加/クリア機能を使用して、チェックボックスを手動でチェック、チェック解除、および無効にすることができます。

 lv_obj_add_statecbLV_STATE_CHECKED; /*チェックボックスをオンにします*/
 lv_obj_clear_statecbLV_STATE_CHECKED; /*チェックボックスをオフにします*/
 lv_obj_add_statecbLV_STATE_CHECKED | LV_STATE_DISABLED; /*チェックボックスをオンにして無効にします*/
戻る : Previous

Events

英文 自動翻訳
  • LV_EVENT_VALUE_CHANGED Sent when the checkbox is toggled.
  • LV_EVENT_DRAW_PART_BEGIN and LV_EVENT_DRAW_PART_END are sent for the following types:
    • LV_CHECKBOX_DRAW_PART_BOX The tickbox of the checkbox
      • part: LV_PART_INDICATOR
      • draw_area: the area of the tickbox
      • rect_dsc

See the events of the Base object too.

Learn more about Events.

  • LV_EVENT_VALUE_CHANGEDチェックボックスが切り替えられたときに送信されます。
  • LV_EVENT_DRAW_PART_BEGINチェックボックスをクリックすると、チェックボックスが切り替わります。LV_EVENT_DRAW_PART_END次のタイプで送信されます 。
    • LV_CHECKBOX_DRAW_PART_BOXチェックボックスのチェックボックス
      • part: LV_PART_INDICATOR
      • draw_area:チェックボックスの領域
      • rect_dsc

Baseオブジェクトのイベントも参照してください。

イベントの詳細をご覧ください。

戻る : Previous


Keys

英文 自動翻訳

The following Keys are processed by the 'Buttons':

  • LV_KEY_RIGHT/UP Go to toggled state if toggling is enabled
  • LV_KEY_LEFT/DOWN Go to non-toggled state if toggling is enabled
  • LV_KEY_ENTER Clicks the checkbox and toggles it


Note that, as usual, the state of LV_KEY_ENTER is translated to LV_EVENT_PRESSED/PRESSING/RELEASED etc.

Learn more about Keys.

次のキーは「ボタン」によって処理されます。
  • LV_KEY_RIGHT/UPトグルが有効になっている場合は、トグル状態になります
  • LV_KEY_LEFT/DOWNトグルが有効になっている場合は、トグルされていない状態になります
  • LV_KEY_ENTERチェックボックスをクリックして切り替えます


通常どおり、LV_KEY_ENTERの状態はLV_EVENT_PRESSED/PRESSING/RELEASEDなどに変換されることに注意してください。


キーの詳細をご覧ください。

戻る : Previous


Example

英文 自動翻訳

Simple Checkboxes

LVGL docs example 069.png

Checkboxes as radio buttons

LVGL docs example 070.png

戻る : Previous


API

英文 自動翻訳

Enums

enum lv_checkbox_draw_part_type_t

type field in lv_obj_draw_part_dsc_t if class_p = lv_checkbox_class Used in LV_EVENT_DRAW_PART_BEGIN and LV_EVENT_DRAW_PART_END Values:
enumerator LV_CHECKBOX_DRAW_PART_BOX
The tick box

Functions

lv_obj_t *lv_checkbox_create(lv_obj_t *parent)

Create a check box object
Parameters
parent -- pointer to an object, it will be the parent of the new button
Returns
pointer to the created check box

void lv_checkbox_set_text(lv_obj_t *obj, const char *txt)

Set the text of a check box. txt will be copied and may be deallocated after this function returns.
Parameters
  • cb -- pointer to a check box
  • txt -- the text of the check box. NULL to refresh with the current text.

void lv_checkbox_set_text_static(lv_obj_t *obj, const char *txt)

Set the text of a check box. txt must not be deallocated during the life of this checkbox.
Parameters
  • cb -- pointer to a check box
  • txt -- the text of the check box.

const char *lv_checkbox_get_text(const lv_obj_t *obj)

Get the text of a check box
Parameters
cb -- pointer to check box object
Returns
pointer to the text of the check box

Variables

const lv_obj_class_t lv_checkbox_class

struct lv_checkbox_t

Public Members
lv_obj_t obj
char *txt
uint32_t static_txt


列挙型

列挙型lv_checkbox_draw_part_type_t

type使用されるlv_obj_draw_part_dsc_t場合のフィールドと値:class_p = lv_checkbox_classチェックボックスをクリックすると、チェックボックスが切り替わります。LV_EVENT_DRAW_PART_BEGINチェックボックスをクリックすると、チェックボックスが切り替わります。LV_EVENT_DRAW_PART_END
列挙子LV_CHECKBOX_DRAW_PART_BOX
チェックボックス

機能

lv_obj_t * lv_checkbox_create(lv_obj_t * parent)

チェックボックスオブジェクトを作成する
パラメーター
親-オブジェクトへのポインタ。新しいボタンの親になります
戻り値
作成されたチェックボックスへのポインタ

void lv_checkbox_set_text(lv_obj_t * obj、const char * txt)

チェックボックスのテキストを設定します。txtコピーされ、この関数が戻った後に割り当てが解除される場合があります。
パラメーター
  • cb-チェックボックスへのポインタ
  • txt-チェックボックスのテキスト。現在のテキストで更新するにはNULL。

void lv_checkbox_set_text_static(lv_obj_t * obj、const char * txt)

チェックボックスのテキストを設定します。txtこのチェックボックスの有効期間中は、割り当てを解除しないでください。
パラメーター
  • cb-チェックボックスへのポインタ
  • txt-チェックボックスのテキスト。

const char * lv_checkbox_get_text(const lv_obj_t * obj)

チェックボックスのテキストを取得する
パラメーター
cb-チェックボックスオブジェクトへのポインタ
戻り値
チェックボックスのテキストへのポインタ

変数

const lv_obj_class_t lv_checkbox_class

struct lv_checkbox_t

パブリックメンバー
lv_obj_t obj
char * txt
uint32_t static_txt


戻る : Previous