Skip to content

Latest commit

 

History

History
executable file
·
220 lines (130 loc) · 5.33 KB

msgbox.rst

File metadata and controls

executable file
·
220 lines (130 loc) · 5.33 KB

Message box(消息框) (lv_msgbox)

Overview(概述)

显示原文

The Message boxes act as pop-ups. They are built from a background container, a title, an optional close button, a text and optional buttons.

The text will be broken into multiple lines automatically and the height will be set automatically to include the text and the buttons.

The message box can be modal (blocking clicks on the rest of the screen) or not modal.


消息框充当弹出窗口。它们是从背景容器、标题、可选的关闭按钮、文本和可选按钮构建的 。

文本将自动分解为多行,高度将自动设置为包含文本和按钮。

消息框可以是模态的(阻止对屏幕其余部分的单击) 或者不是模态。

Parts and Styles(零件和样式)

显示原文

The message box is built from other widgets, so you can check these widgets' documentation for details.

  • Background: lv_obj
  • Close button: lv_button
  • Title and text: lv_label
  • Buttons: lv_buttonmatrix

消息框是从其他控件构建的,因此您可以选中这些控件的文档了解详细信息。

  • 背景: lv_obj
  • 关闭按钮: lv_button
  • 标题和文本:lv_label
  • 按钮:lv_buttonmatrix

Usage(用法)

Create a message box(创建消息框)

显示原文

:cpplv_msgbox_create(parent, title, txt, btn_txts[], add_close_btn) creates a message box.

If parent is NULL the message box will be modal. title and txt are strings for the title and the text. btn_txts[] is an array with the buttons' text.

E.g. :cppconst char * btn_txts[] = {"Ok", "Cancel", NULL}. add_close_btn can be true or false to add/don't add a close button.


:cpplv_msgbox_create(parent, title, txt, btn_txts[], add_close_btn) 创建一个消息框。

如果 parentNULL ,则消息框将是模态的。 titletxt 是标题和文本的字符串。 btn_txts[] 是一个数组替换为按钮的文本。

例如 :cppconst char * btn_txts[] = {"Ok", "Cancel", NULL}add_close_btn 可以是 truefalse 添加/不添加关闭按钮。

Get the parts(获取零件)

显示原文

The building blocks of the message box can be obtained using the following functions:


消息框的构建块可以使用 以下功能:

lv_obj_t * lv_msgbox_get_title(lv_obj_t * mbox);
lv_obj_t * lv_msgbox_get_close_btn(lv_obj_t * mbox);
lv_obj_t * lv_msgbox_get_text(lv_obj_t * mbox);
lv_obj_t * lv_msgbox_get_btns(lv_obj_t * mbox);

Close the message box(关闭消息框)

显示原文

:cpplv_msgbox_close(msgbox) closes (deletes) the message box.


:cpplv_msgbox_close(msgbox) 关闭(删除)消息框。

Events(事件)

显示原文
  • :cppLV_EVENT_VALUE_CHANGED is sent by the buttons if one of them is clicked. :cppLV_OBJ_FLAG_EVENT_BUBBLE is enabled on the buttons so you can add events to the message box itself. In the event handler, :cpplv_event_get_target(e) will return the button matrix and :cpplv_event_get_current_target(e) will return the message box. :cpplv_msgbox_get_active_button(msgbox) and :cpplv_msgbox_get_active_button_text(msgbox) can be used to get the index and text of the clicked button.

Learn more about events.


  • :cppLV_EVENT_VALUE_CHANGED 如果其中一个按钮是 点击。 :cppLV_OBJ_FLAG_EVENT_BUBBLE 在按钮上启用,因此您可以将事件添加到消息框本身。在事件处理程序中, :cpplv_event_get_target(e) 将返回按钮矩阵 ,:cpplv_event_get_current_target(e) 将返回消息框。:cpplv_msgbox_get_active_button(msgbox) 和 :cpplv_msgbox_get_active_button_text(msgbox) 可用于获取单击按钮的索引和文本。

详细了解更多 events

Keys(按键)

显示原文

Keys have effect on the close button and button matrix. You can add them manually to a group if required.

Learn more about indev_keys.


按键对关闭按钮和按钮矩阵有影响。您可以添加它们如果需要,手动添加到组中。。

了解有关 indev_keys 的更多信息。

Example

API