App:Library:LVGL:docs:Widgets:Keyboard (lv keyboard)

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

https://docs.lvgl.io/8.2/widgets/extra/keyboard.html

Keyboard (lv_keyboard)

Overview

英文 自動翻訳

The Keyboard object is a special Button matrix with predefined keymaps and other features to realize a virtual keyboard to write texts into a Text area.

Keyboardオブジェクトは、Textエリアにテキストを書き込むための仮想キーボードを実現するために、あらかじめ定義されたキーマップとその他の機能を持つ特別なButtonマトリックスです。
戻る : Previous


Parts and Styles

英文 自動翻訳

Similarly to Button matrices Keyboards consist of 2 part:

  • LV_PART_MAIN The main part. Uses all the typical background properties
  • LV_PART_ITEMS The buttons. Also uses all typical background properties as well as the text properties.
ボタン行列と同様に、キーボードも2つの部分から構成される。
  • LV_PART_MAIN メインパート。すべての典型的な背景プロパティを使用します。
  • LV_PART_ITEMS ボタン。テキストプロパティと同様に、すべての典型的な背景プロパティを使用します。
戻る : Previous


Usage

Modes

英文 自動翻訳

The Keyboards have the following modes:

  • LV_KEYBOARD_MODE_TEXT_LOWER Display lower case letters
  • LV_KEYBOARD_MODE_TEXT_UPPER Display upper case letters
  • LV_KEYBOARD_MODE_TEXT_SPECIAL Display special characters
  • LV_KEYBOARD_MODE_NUMBER Display numbers, +/- sign, and decimal dot
  • LV_KEYBOARD_MODE_USER_1 through LV_KEYBOARD_MODE_USER_4 User-defined modes.


The TEXT modes' layout contains buttons to change mode.

To set the mode manually, use lv_keyboard_set_mode(kb, mode). The default mode is LV_KEYBOARD_MODE_TEXT_UPPER.

Keyboardsには以下のモードがあります。
  • LV_KEYBOARD_MODE_TEXT_LOWER小文字を表示する。
  • LV_KEYBOARD_MODE_TEXT_UPPER 大文字を表示する。
  • LV_KEYBOARD_MODE_TEXT_SPECIAL 特殊文字を表示する。
  • LV_KEYBOARD_MODE_NUMBER 数字、+/-記号、小数点の表示
  • LV_KEYBOARD_MODE_USER_1LV_KEYBOARD_MODE_USER_4 ユーザー定義モードです。


TEXTモードのレイアウトには、モードを変更するためのボタンがあります。

モードを手動で設定するには、lv_keyboard_set_mode(kb, mode)を使用します。デフォルトのモードは、 LV_KEYBOARD_MODE_TEXT_UPPERです。

戻る : Previous


Assign Text area

英文 自動翻訳

You can assign a Text area to the Keyboard to automatically put the clicked characters there. To assign the text area, use lv_keyboard_set_textarea(kb, ta).

キーボードにテキストエリアを割り当てて、クリックした文字を自動的にそこに配置することができます。テキストエリアを割り当てるには、lv_keyboard_set_textarea(kb, ta)を使用します。
戻る : Previous


Key Popovers

英文 自動翻訳

To enable key popovers on press, like on common Android and iOS keyboards, use lv_keyboard_set_popovers(kb, true).


The default control maps are preconfigured to only show the popovers on keys that produce a symbol and not on e.g. space.

If you use a custom keymap, set the LV_BTNMATRIX_CTRL_POPOVER flag for all keys that you want to show a popover.


Note that popovers for keys in the top row will draw outside the widget boundaries.

To account for this, reserve extra free space on top of the keyboard or ensure that the keyboard is added after any widgets adjacent to its top boundary so that the popovers can draw over those.

The popovers currently are merely a visual effect and don't allow selecting additional characters such as accents yet.

キーボードにテキストエリアを割り当てて、クリックした文字を自動的にそこに配置することができます。テキストエリアを割り当てるには、lv_keyboard_seを使用します。一般的なAndroidやiOSのキーボードのように、押したときにキーのポップオーバーを有効にするには、lv_keyboard_set_popovers(kb, true)を使用します。


デフォルトのコントロールマップは、シンボルを生成するキーにのみポップオーバーを表示し、スペースなどには表示しないようにあらかじめ設定されています。

カスタムのキーマップを使用する場合は、ポップオーバーを表示したいすべてのキーにLV_BTNMATRIX_CTRL_POPOVERフラグを設定します。


一番上の行にあるキーのポップオーバーは、ウィジェットの境界の外に描画されることに注意してください。

このため、キーボードの上に空きスペースを確保するか、キーボードをウィジェット上部の境界線に隣接するウィジェットの後に追加して、ポップオーバーがそれらの上に描画されるようにします。


現在、ポップオーバーは単なる視覚効果であり、アクセントなどの追加文字を選択することはまだできません。

戻る : Previous


New Keymap

英文 自動翻訳

You can specify a new map (layout) for the keyboard with lv_keyboard_set_map(kb, map) and lv_keyboard_set_ctrl_map(kb, ctrl_map).

Learn more about the Button matrix object.

Keep in mind that using following keywords will have the same effect as with the original map:

  • LV_SYMBOL_OK Apply.
  • LV_SYMBOL_CLOSE or LV_SYMBOL_KEYBOARD Close.
  • LV_SYMBOL_BACKSPACE Delete on the left.
  • LV_SYMBOL_LEFT Move the cursor left.
  • LV_SYMBOL_RIGHT Move the cursor right.
  • LV_SYMBOL_NEW_LINE New line.
  • "ABC" Load the uppercase map.
  • "abc" Load the lower case map.
  • "1#" Load the lower case map.
キーボードの新しいマップ(レイアウト)は、 lv_keyboard_set_map(kb, map)lv_keyboard_set_ctrl_map(kb, ctrl_map). で指定することができます。

ボタンマトリックスオブジェクトについてはこちらをご覧ください。

以下のキーワードを使用しても、オリジナルのマップと同じ効果が得られることに留意してください。

  • LV_SYMBOL_OK 適用.
  • LV_SYMBOL_CLOSE or LV_SYMBOL_KEYBOARD 閉じる
  • LV_SYMBOL_BACKSPACE 左側を削除
  • LV_SYMBOL_LEFT カーソルを左に移動させる。
  • LV_SYMBOL_RIGHT カーソルを右に移動させる。
  • LV_SYMBOL_NEW_LINE 新しい行
  • "ABC" 大文字の地図を読み込む。
  • "abc" 小文字のマップを読み込む。
  • "1#" 小文字のマップを読み込む。
戻る : Previous


Events

英文 自動翻訳
  • LV_EVENT_VALUE_CHANGED Sent when the button is pressed/released or repeated after long press. The event data is set to the ID of the pressed/released button.
  • LV_EVENT_READY - The Ok button is clicked.
  • LV_EVENT_CANCEL - The Close button is clicked.


The keyboard has a default event handler callback called lv_keyboard_def_event_cb, which handles the button pressing, map changing, the assigned text area, etc.

You can remove it and replace it with a custom event handler if you wish.

Note

In 8.0 and newer, adding an event handler to the keyboard does not remove the default event handler.

This behavior differs from v7, where adding an event handler would always replace the previous one.

Learn more about Events.

  • LV_EVENT_VALUE_CHANGED ボタンが押されたとき/離されたとき/長押しで繰り返されたときに送信され る。イベントデータには押下/離脱されたボタンのIDが設定されます。
  • LV_EVENT_READY - Okボタンが押されたとき。
  • LV_EVENT_CANCEL - クローズボタンが押されたとき。


キーボードには、 lv_keyboard_def_event_cbというデフォルトのイベントハンドラーコールバックがあり、ボタン押下、マップ変更、割り当てられたテキストエリアなどを処理します。


備考

8.0以降では、キーボードにイベントハンドラを追加しても、デフォルトイベントハンドラは削除されません。

この動作は、イベントハンドラを追加すると常に前のイベントハンドラを置き換えるv7とは異なります。


イベントの詳細を確認してください。

戻る : Previous


Keys

英文 自動翻訳
  • LV_KEY_RIGHT/UP/LEFT/RIGHT To navigate among the buttons and select one.
  • LV_KEY_ENTER To press/release the selected button.


Learn more about Keys.

  • LV_KEY_RIGHT/UP/LEFT/RIGHT ボタン間を移動して選択します。
  • LV_KEY_ENTER 選択したボタンを押す/離す。


キーの詳細を確認してください。

戻る : Previous


Examples

英文 自動翻訳

Keyboard with text area

LVGL docs example 080.png

戻る : Previous


API

英文 自動翻訳

Typedefs

typedef uint8_t lv_keyboard_mode_t

Enums

enum [anonymous]

Current keyboard mode. Values:
enumerator LV_KEYBOARD_MODE_TEXT_LOWER
enumerator LV_KEYBOARD_MODE_TEXT_UPPER
enumerator LV_KEYBOARD_MODE_SPECIAL
enumerator LV_KEYBOARD_MODE_NUMBER
enumerator LV_KEYBOARD_MODE_USER_1
enumerator LV_KEYBOARD_MODE_USER_2
enumerator LV_KEYBOARD_MODE_USER_3
enumerator LV_KEYBOARD_MODE_USER_4

Functions

lv_obj_t *lv_keyboard_create(lv_obj_t *parent)

Create a Keyboard object
Parameters
parent -- pointer to an object, it will be the parent of the new keyboard
Returns
pointer to the created keyboard

void lv_keyboard_set_textarea(lv_obj_t *kb, lv_obj_t *ta)

Assign a Text Area to the Keyboard. The pressed characters will be put there.
Parameters
  • kb -- pointer to a Keyboard object
  • ta -- pointer to a Text Area object to write there

void lv_keyboard_set_mode(lv_obj_t *kb, lv_keyboard_mode_t mode)

Set a new a mode (text or number map)
Parameters
  • kb -- pointer to a Keyboard object
  • mode -- the mode from 'lv_keyboard_mode_t'

void lv_keyboard_set_popovers(lv_obj_t *kb, bool en)

Show the button title in a popover when pressed.
Parameters
  • kb -- pointer to a Keyboard object
  • en -- whether "popovers" mode is enabled

void lv_keyboard_set_map(lv_obj_t *kb, lv_keyboard_mode_t mode, const char *map[], const lv_btnmatrix_ctrl_t ctrl_map[])

Set a new map for the keyboard
Parameters
  • kb -- pointer to a Keyboard object
  • mode -- keyboard map to alter 'lv_keyboard_mode_t'
  • map -- pointer to a string array to describe the map. See 'lv_btnmatrix_set_map()' for more info.

lv_obj_t *lv_keyboard_get_textarea(const lv_obj_t *kb)

Assign a Text Area to the Keyboard. The pressed characters will be put there.
Parameters
kb -- pointer to a Keyboard object
Returns
pointer to the assigned Text Area object

lv_keyboard_mode_t lv_keyboard_get_mode(const lv_obj_t *kb)

Set a new a mode (text or number map)
Parameters
kb -- pointer to a Keyboard object
Returns
the current mode from 'lv_keyboard_mode_t'

bool lv_btnmatrix_get_popovers(const lv_obj_t *obj)

Tell whether "popovers" mode is enabled or not.
Parameters
kb -- pointer to a Keyboard object
Returns
true: "popovers" mode is enabled; false: disabled

static inline const char **lv_keyboard_get_map_array(const lv_obj_t *kb)

Get the current map of a keyboard
Parameters
kb -- pointer to a keyboard object
Returns
the current map

static inline uint16_t lv_keyboard_get_selected_btn(const lv_obj_t *obj)

Get the index of the lastly "activated" button by the user (pressed, released, focused etc) Useful in the event_cb to get the text of the button, check if hidden etc.
Parameters
obj -- pointer to button matrix object
Returns
index of the last released button (LV_BTNMATRIX_BTN_NONE: if unset)

static inline const char *lv_keyboard_get_btn_text(const lv_obj_t *obj, uint16_t btn_id)

Get the button's text
Parameters
  • obj -- pointer to button matrix object
  • btn_id -- the index a button not counting new line characters.
Returns
text of btn_index` button

void lv_keyboard_def_event_cb(lv_event_t *e)

Default keyboard event to add characters to the Text area and change the map. If a custom event_cb is added to the keyboard this function can be called from it to handle the button clicks
Parameters
  • kb -- pointer to a keyboard
  • event -- the triggering event

Variables

const lv_obj_class_t lv_keyboard_class

struct lv_keyboard_t

Public Members
lv_btnmatrix_t btnm
lv_obj_t *ta
lv_keyboard_mode_t mode
uint8_t popovers
Typedefs

typedef uint8_t lv_keyboard_mode_t

Enums

enum [anonymous]

現在のキーボードモード。値です。
enumerator LV_KEYBOARD_MODE_TEXT_LOWER
enumerator LV_KEYBOARD_MODE_TEXT_UPPER
enumerator LV_KEYBOARD_MODE_SPECIAL
enumerator LV_KEYBOARD_MODE_NUMBER
enumerator LV_KEYBOARD_MODE_USER_1
enumerator LV_KEYBOARD_MODE_USER_2
enumerator LV_KEYBOARD_MODE_USER_3
enumerator LV_KEYBOARD_MODE_USER_4

Functions

lv_obj_t *lv_keyboard_create(lv_obj_t *parent)

キーボードオブジェクトを作成する
Parameters
parent -- オブジェクトへのポインタ、それは新しいキーボードの親になります
Returns
作成されたキーボードへのポインタ

void lv_keyboard_set_textarea(lv_obj_t *kb, lv_obj_t *ta)

キーボードにテキスト領域を割り当てます。 押された文字がそこに置かれます。
Parameters
  • kb -- キーボードオブジェクトへのポインタ
  • ta -- そこに書き込むテキストエリアオブジェクトへのポインタ

void lv_keyboard_set_mode(lv_obj_t *kb, lv_keyboard_mode_t mode)

新しいモードを設定する(テキストまたは番号マップ)
Parameters
  • kb -- キーボードオブジェクトへのポインタ
  • mode -- 'lv_keyboard_mode_t'からのモード

void lv_keyboard_set_popovers(lv_obj_t *kb, bool en)

Show the button title in a popover when pressed.
Parameters
  • kb -- キーボードオブジェクトへのポインタ
  • en -- 「ポップオーバー」モードが有効かどうか

void lv_keyboard_set_map(lv_obj_t *kb, lv_keyboard_mode_t mode, const char *map[], const lv_btnmatrix_ctrl_t ctrl_map[])

Set a new map for the keyboard
Parameters
  • kb -- キーボードオブジェクトへのポインタ
  • mode --'lv_keyboard_mode_t'を変更するキーボードマップ
  • map -- マップを説明する文字列配列へのポインタ。 詳細については、「lv_btnmatrix_set_map()」を参照してください。

lv_obj_t *lv_keyboard_get_textarea(const lv_obj_t *kb)

キーボードにテキスト領域を割り当てます。 押された文字がそこに置かれます。
Parameters
kb -- キーボードオブジェクトへのポインタ
Returns
割り当てられたテキストエリアオブジェクトへのポインタ

lv_keyboard_mode_t lv_keyboard_get_mode(const lv_obj_t *kb)

新しいモードを設定する(テキストまたは番号マップ)
Parameters
kb -- キーボードオブジェクトへのポインタ
Returns
'lv_keyboard_mode_t'からの現在のモード

bool lv_btnmatrix_get_popovers(const lv_obj_t *obj)

「ポップオーバー」モードが有効になっているかどうかを確認します。
Parameters
kb -- キーボードオブジェクトへのポインタ
Returns
true:「ポップオーバー」モードが有効になっています。 false:無効

static inline const char **lv_keyboard_get_map_array(const lv_obj_t *kb)

キーボードの現在のマップを取得する
Parameters
kb -- キーボードの現在のマップを取得する
Returns
現在の地図

static inline uint16_t lv_keyboard_get_selected_btn(const lv_obj_t *obj)

ユーザーが最後に「アクティブ化した」ボタンのインデックスを取得します(押された、離された、フォーカスされたなど)event_cb でボタンのテキストを取得したり、非表示になっているかどうかを確認したりするのに役立ちます。
Parameters
obj -- ボタンマトリックスオブジェクトへのポインタ
Returns
最後にリリースされたボタンのインデックス(LV_BTNMATRIX_BTN_NONE:設定されていない場合)

static inline const char *lv_keyboard_get_btn_text(const lv_obj_t *obj, uint16_t btn_id)

ボタンのテキストを取得する
Parameters
  • obj -- ボタンマトリックスオブジェクトへのポインタ
  • btn_id -- インデックスは、改行文字をカウントしないボタンです。
Returns
btn_index`ボタンのテキスト

void lv_keyboard_def_event_cb(lv_event_t *e)

テキスト領域に文字を追加してマップを変更するためのデフォルトのキーボードイベント。 カスタム event_cb がキーボードに追加された場合、この関数をキーボードから呼び出して、ボタンのクリックを処理できます。
Parameters
  • kb -- キーボードへのポインタ
  • event -- トリガーイベント

Variables

const lv_obj_class_t lv_keyboard_class

struct lv_keyboard_t

Public Members
lv_btnmatrix_t btnm
lv_obj_t *ta
lv_keyboard_mode_t mode
uint8_t popovers


戻る : Previous