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では、ユーザが興味を持ちそうなことが起こったときに、イベントが発生します。
|
The user can assign a callback function to an object to see these events.
In practice, it looks like this: |
ユーザーは、コールバック関数をオブジェクトに割り当てて、これらのイベントを確認できます。
実際には、次のようになります。 |
lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL);
lv_obj_set_event_cb(btn, my_event_cb); /*Assign an event callback*/
...
static void my_event_cb(lv_obj_t * obj, lv_event_t event)
{
switch(event) {
case LV_EVENT_PRESSED:
printf("Pressed\n");
break;
case LV_EVENT_SHORT_CLICKED:
printf("Short clicked\n");
break;
case LV_EVENT_CLICKED:
printf("Clicked\n");
break;
case LV_EVENT_LONG_PRESSED:
printf("Long press\n");
break;
case LV_EVENT_LONG_PRESSED_REPEAT:
printf("Long press repeat\n");
break;
case LV_EVENT_RELEASED:
printf("Released\n");
break;
}
/*Etc.*/
}
| |
More objects can use the same event callback. | より多くのオブジェクトが同じイベント コールバックを使用できます。 |
Event types
The following event types exist: | 次のイベント タイプが存在します。 |
Generic events
All objects (such as Buttons/Labels/Sliders etc.) receive these generic events regardless of their type. | すべてのオブジェクト (ボタン/ラベル/スライダーなど) は、タイプに関係なく、これらの一般的なイベントを受け取ります。 |
Related to the input devices
These are sent when an object is pressed/released etc. by the user. They are used not only for Pointers but can used for Keypad, Encoder and Button input devices as well. Visit the Overview of input devices section to learn more about them.
|
これらは、ユーザーがオブジェクトを押したり離したりしたときに送信されます。ポインターだけでなく、キーパッド、エンコーダー、ボタン入力デバイスにも使用できます。詳細については、入力デバイスの概要セクションをご覧ください。
|
Related to pointer
These events are sent only by pointer-like input devices (E.g. mouse or touchpad)
|
これらのイベントは、ポインターのような入力デバイス (マウスやタッチパッドなど) によってのみ送信されます。
|
Related to keypad and encoder
These events are sent by keypad and encoder input devices. Learn more about Groups in [overview/indev](Input devices) section.
|
これらのイベントは、キーパッドとエンコーダの入力デバイスによって送信されます。 グループの詳細については、[概要/indev](入力デバイス) セクションを参照してください。
LV_EVENT_KEY オブジェクトにキーが送信されます。 通常、長押しの後に押された、または繰り返されたとき。 キーは uint32_t * key = lv_event_get_data() で取得できます LV_EVENT_FOCUSED オブジェクトはそのグループにフォーカスされています LV_EVENT_DEFOCUSED オブジェクトはそのグループ内で焦点が合っていません |
General events
Other general events sent by the library.
|
図書館から送られるその他の一般的なイベント。
|
Special events
These events are specific to a particular object type.
Visit particular Object type's documentation to understand which events are used by an object type. |
これらのイベントは、特定のオブジェクト タイプに固有です。
オブジェクト タイプで使用されるイベントを理解するには、特定のオブジェクト タイプのドキュメントを参照してください。 |
Custom data
Some events might contain custom data. For example, LV_EVENT_VALUE_CHANGED in some cases tells the new value. For more information, see the particular Object type's documentation. To get the custom data in the event callback use lv_event_get_data() .
The type of the custom data depends on the sending object but if it's a
|
一部のイベントには、カスタム データが含まれる場合があります。 たとえば、場合によっては LV_EVENT_VALUE_CHANGED が新しい値を示します。 詳細については、特定のオブジェクト タイプのドキュメントを参照してください。 イベント コールバックでカスタム データを取得するには、lv_event_get_data() を使用します。
カスタム データのタイプは送信オブジェクトによって異なりますが、
|
Send events manually
Arbitrary events
To manually send events to an object, use lv_event_send(obj, LV_EVENT_..., &custom_data) .
For example, it can be used to manually close a message box by simulating a button press (although there are simpler ways of doing this): |
イベントをオブジェクトに手動で送信するには、lv_event_send(obj, LV_EVENT_..., &custom_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 is special event because it's designed to be used by the user to notify an object to refresh itself. Some examples:
To simplest way to handle similar cases is utilizing the following functions.
|
LV_EVENT_REFRESH は、オブジェクト自体を更新するように通知するためにユーザーが使用するように設計されているため、特別なイベントです。 いくつかの例:
同様のケースを処理する最も簡単な方法は、次の関数を利用することです。 lv_event_send_refresh(obj) は、lv_event_send(obj, LV_EVENT_REFRESH, NULL) の単なるラッパーです。 したがって、LV_EVENT_REFRESH をオブジェクトに送信するだけです。 lv_event_send_refresh_recursive(obj) は、LV_EVENT_REFRESH イベントをオブジェクトとそのすべての子に送信します。 パラメータとして NULL が渡された場合、すべてのディスプレイのすべてのオブジェクトがリフレッシュされます。 |