Skip to content

Commit

Permalink
Support TextCapitalization (#344)
Browse files Browse the repository at this point in the history
* Contribute #195
* Add a constant string for textCapitalization

Signed-off-by: Boram Bae <[email protected]>
  • Loading branch information
bbrto21 authored Sep 16, 2022
1 parent 1fe47b4 commit 16c67da
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions shell/platform/tizen/channels/text_input_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ constexpr char kUpdateEditingStateMethod[] =
"TextInputClient.updateEditingState";
constexpr char kPerformActionMethod[] = "TextInputClient.performAction";
constexpr char kSetPlatformViewClient[] = "TextInput.setPlatformViewClient";
constexpr char kTextCapitalization[] = "textCapitalization";
constexpr char kTextInputAction[] = "inputAction";
constexpr char kTextInputType[] = "inputType";
constexpr char kTextInputTypeName[] = "name";
Expand Down Expand Up @@ -168,6 +169,15 @@ void TextInputChannel::HandleMethodCall(
input_action_ = input_action_iter->value.GetString();
}

text_capitalization_ = "";
auto text_capitalization_iter =
client_config.FindMember(kTextCapitalization);
if (text_capitalization_iter != client_config.MemberEnd() &&
text_capitalization_iter->value.IsString()) {
text_capitalization_ = text_capitalization_iter->value.GetString();
input_method_context_->SetAutocapitalType(text_capitalization_);
}

input_type_ = "";
auto input_type_info_iter = client_config.FindMember(kTextInputType);
if (input_type_info_iter != client_config.MemberEnd() &&
Expand Down
4 changes: 4 additions & 0 deletions shell/platform/tizen/channels/text_input_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ class TextInputChannel {
// Keyboard type of the client. See available options:
// https://api.flutter.dev/flutter/services/TextInputType-class.html
std::string input_type_;

// Automatic text capitalization type. See available options:
// https://api.flutter.dev/flutter/services/TextCapitalization.html
std::string text_capitalization_ = "";
};

} // namespace flutter
Expand Down
15 changes: 15 additions & 0 deletions shell/platform/tizen/tizen_input_method_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,21 @@ void TizenInputMethodContext::SetInputPanelLayoutVariation(bool is_signed,
ecore_imf_context_input_panel_layout_variation_set(imf_context_, variation);
}

void TizenInputMethodContext::SetAutocapitalType(const std::string& type) {
Ecore_IMF_Autocapital_Type autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_NONE;

if (type == "TextCapitalization.characters") {
autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_ALLCHARACTER;
} else if (type == "TextCapitalization.words") {
autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_WORD;
} else if (type == "TextCapitalization.sentences") {
autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE;
} else if (type == "TextCapitalization.none") {
autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_NONE;
}
ecore_imf_context_autocapital_type_set(imf_context_, autocapital_type);
}

void TizenInputMethodContext::RegisterEventCallbacks() {
FT_ASSERT(imf_context_);

Expand Down
2 changes: 2 additions & 0 deletions shell/platform/tizen/tizen_input_method_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class TizenInputMethodContext {

void SetInputPanelLayoutVariation(bool is_signed, bool is_decimal);

void SetAutocapitalType(const std::string& type);

void SetOnCommit(OnCommit callback) { on_commit_ = callback; }

void SetOnPreeditChanged(OnPreeditChanged callback) {
Expand Down

0 comments on commit 16c67da

Please sign in to comment.