App:Library:LVGL:docs:Overview:Events
https://docs.lvgl.io/8.2/overview/event.html
Events
英文 | 自動翻訳 |
---|---|
Events are triggered in LVGL when something happens which might be interesting to the user, e.g. when an object
|
LVGLでは、ユーザが興味を持ちそうなことが起こったときに、イベントが発生します。
|
Add events to the object
英文 | 自動翻訳 |
---|---|
The user can assign callback functions to an object to see its events. In practice, it looks like this: lv_obj_t * btn = lv_btn_create(lv_scr_act());
lv_obj_add_event_cb(btn, my_event_cb, LV_EVENT_CLICKED, NULL); /*Assign an event callback*/
...
static void my_event_cb(lv_event_t * event)
{
printf("Clicked\n");
}
In the example See the list of event codes for all the options.
It will be described later in more detail. More events can be added to an object, like this: lv_obj_add_event_cb(obj, my_event_cb_1, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(obj, my_event_cb_2, LV_EVENT_PRESSED, NULL);
lv_obj_add_event_cb(obj, my_event_cb_3, LV_EVENT_ALL, NULL); /*No filtering, receive all events*/
Even the same event callback can be used on an object with different For example: lv_obj_add_event_cb(obj, increment_on_click, LV_EVENT_CLICKED, &num1);
lv_obj_add_event_cb(obj, increment_on_click, LV_EVENT_CLICKED, &num2);
The events will be called in the order as they were added. Other objects can use the same event callback. |
ユーザーは、オブジェクトにコールバック関数を割り当てて、そのイベントを確認することができます。
実際には、以下のような感じです。 lv_obj_t * btn = lv_btn_create(lv_scr_act());
lv_obj_add_event_cb(btn, my_event_cb, LV_EVENT_CLICKED, NULL); /*Assign an event callback*/
...
static void my_event_cb(lv_event_t * event)
{
printf("Clicked\n");
}
この例では、 すべてのオプションについては、イベントコードのリストを参照してください。
これについては、後で詳しく説明します。 このように、オブジェクトにはさらにイベントを追加することができます。 lv_obj_add_event_cb(obj, my_event_cb_1, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(obj, my_event_cb_2, LV_EVENT_PRESSED, NULL);
lv_obj_add_event_cb(obj, my_event_cb_3, LV_EVENT_ALL, NULL); /*No filtering, receive all events*/
同じイベントコールバックでも、 例えば lv_obj_add_event_cb(obj, increment_on_click, LV_EVENT_CLICKED, &num1);
lv_obj_add_event_cb(obj, increment_on_click, LV_EVENT_CLICKED, &num2);
イベントは、追加された順番に呼び出されます。 他のオブジェクトも同じイベントコールバックを使用することができます。 |
Remove event(s) from an object
英文 | 自動翻訳 |
---|---|
Events can be removed from an object with the
|
イベントは、lv_obj_remove_event_cb(obj, event_cb) 関数または lv_obj_remove_event_dsc(obj, event_dsc) . でオブジェクトから削除できる。
|
Event codes
英文 | 自動翻訳 |
---|---|
The event codes can be grouped into these categories:
All objects (such as Buttons/Labels/Sliders etc.) regardless their type receive the Input device, Drawing and Other events. However, the Special events are specific to a particular widget type. See the widgets' documentation to learn when they are sent, Custom events are added by the user and are never sent by LVGL. The following event codes exist: |
イベントコードは、以下のカテゴリーに分類されます。
すべてのオブジェクト(ボタン/ラベル/スライダーなど)は、そのタイプに関係なく、Input device、Drawing、Otherの各イベントを受け取ります。 しかし、特別なイベントは、特定のウィジェットタイプに固有のものです。いつ送信されるかは、ウィジェットのドキュメントを参照してください。 カスタムイベントはユーザが追加するもので、LVGLから送信されることはありません。 以下のイベントコードが存在する。 |
Input device events
英文 | 自動翻訳 |
---|---|
|
|
Drawing events
英文 | 自動翻訳 |
---|---|
In |
In |
Other events
英文 | 自動翻訳 |
---|---|
|
|
Special events
英文 | 自動翻訳 |
---|---|
|
|
Custom events
英文 | 自動翻訳 |
---|---|
Any custom event codes can be registered by They can be sent to any object with |
カスタムイベントコードは、uint32_t MY_EVENT_1 = lv_event_register_id(); で登録することができます。
任意のオブジェクトに |
Sending events
英文 | 自動翻訳 |
---|---|
To manually send events to an object, use For example, this can be used to manually close a message box by simulating a button press (although there are simpler ways to do this): /*Simulate the press of the first button (indexes start from zero)*/
uint32_t btn_id = 0;
lv_event_send(mbox, LV_EVENT_VALUE_CHANGED, &btn_id);
|
手動でオブジェクトにイベントを送るには、lv_event_send(obj, <EVENT_CODE> &some_data) .を使ってください。
例えば、ボタンを押したように見えるメッセージボックスを手動で閉じることができます(もっと簡単な方法もありますが)。 /*Simulate the press of the first button (indexes start from zero)*/
uint32_t btn_id = 0;
lv_event_send(mbox, LV_EVENT_VALUE_CHANGED, &btn_id);
|
Refresh event
英文 | 自動翻訳 |
---|---|
|
LV_EVENT_REFRESH は特別なイベントで、オブジェクトの更新をユーザに通知するように設計されているからです。いくつかの例を挙げます。
|
Fields of lv_event_t
英文 | 自動翻訳 |
---|---|
|
lv_event_t は、イベントコールバックに渡される唯一のパラメータで、イベントに関するすべてのデータを含んでいます。そこから以下の値を得ることができる。
|
Event bubbling
英文 | 自動翻訳 |
---|---|
If
|
If lv_obj_add_flag(obj, LV_OBJ_FLAG_EVENT_BUBBLE) が有効な場合、すべてのイベントはオブジェクトの親にも送信されます。
|
Examples
英文 | 自動翻訳 |
---|---|
Button click event |
|
Handle multiple events |
|
Event bubbling |