Skip to content

Commit

Permalink
Use TextInputType when showing software keyboard
Browse files Browse the repository at this point in the history
Signed-off-by: Boram Bae <boram21.bae@samsung.com>
  • Loading branch information
bbrto21 committed May 24, 2021
1 parent 9f408ef commit ca8c9a2
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions shell/platform/tizen/channels/text_input_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,45 @@ static bool IsASCIIPrintableKey(char c) {
return false;
}

static bool TextInputTypeToEcoreIMFInputPanelLayout(
std::string text_input_type,
Ecore_IMF_Input_Panel_Layout& panel_layout) {
FT_LOGI("text_input_type[%s]", text_input_type.c_str());
bool ret = false;
if (text_input_type == "TextInputType.text" ||
text_input_type == "TextInputType.multiline") {
panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
ret = true;
} else if (text_input_type == "TextInputType.number") {
panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER;
ret = true;
} else if (text_input_type == "TextInputType.phone") {
panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER;
ret = true;
} else if (text_input_type == "TextInputType.datetime") {
panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_DATETIME;
ret = true;
} else if (text_input_type == "TextInputType.emailAddress") {
panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL;
ret = true;
} else if (text_input_type == "TextInputType.url") {
panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_URL;
ret = true;
} else if (text_input_type == "TextInputType.visiblePassword") {
panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD;
ret = true;
} else if (text_input_type == "TextInputType.name" ||
text_input_type == "TextInputType.address") {
FT_LOGW(
"Actual requested text input type is [%s], but select "
"TextInputType.text as fallback type",
text_input_type.c_str());
panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
ret = true;
}
return ret;
}

void TextInputChannel::CommitCallback(void* data,
Ecore_IMF_Context* ctx,
void* event_info) {
Expand Down Expand Up @@ -586,6 +625,10 @@ void TextInputChannel::ShowSoftwareKeyboard() {
FT_LOGD("Show input panel");
if (imf_context_ && !is_software_keyboard_showing_) {
is_software_keyboard_showing_ = true;
Ecore_IMF_Input_Panel_Layout panel_layout;
if (TextInputTypeToEcoreIMFInputPanelLayout(input_type_, panel_layout)) {
ecore_imf_context_input_panel_layout_set(imf_context_, panel_layout);
}
ecore_imf_context_input_panel_show(imf_context_);
ecore_imf_context_focus_in(imf_context_);
}
Expand Down

0 comments on commit ca8c9a2

Please sign in to comment.