MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / startTextInput

Function startTextInput

src/AndroidJNICalls.cpp:127–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125 }
126
127 void startTextInput(CustomEvents::InputTextBoxID newTextboxID, const std::shared_ptr<RichText::TextBox>& newTextbox, const std::shared_ptr<RichText::TextBox::Cursor>& newCursor, const std::shared_ptr<RichText::TextStyleModifier::ModifierMap>& newModMap, int inputType) {
128 std::scoped_lock a{textboxMutex};
129 if(!textBox) {
130 textBox = std::make_shared<RichText::TextBox>();
131 cursor = std::make_shared<RichText::TextBox::Cursor>();
132 }
133
134 textChanged = false;
135 cursorChanged = false;
136
137 textboxID = newTextboxID;
138 textBox->set_rich_text_data(newTextbox->get_rich_text_data());
139 *cursor = *newCursor;
140
141 if(newModMap)
142 modMap = std::make_shared<RichText::TextStyleModifier::ModifierMap>(*newModMap);
143 else
144 modMap = nullptr;
145
146 JNIEnv* env = static_cast<JNIEnv*>(SDL_GetAndroidJNIEnv());
147 jni_local_frame(env, 16, [&] {
148 jobject activity = (jobject) SDL_GetAndroidActivity();
149 jclass clazz = env->GetObjectClass(activity);
150 jmethodID method_id = env->GetStaticMethodID(clazz, "startTextInput",
151 "(JLjava/lang/String;III)V");
152 env->CallStaticVoidMethod(clazz, method_id, textboxID,
153 string2jstring(env, textBox->get_string()),
154 get_android_text_pos_from_cursor_pos(textBox, std::min(
155 cursor->selectionBeginPos, cursor->selectionEndPos)),
156 get_android_text_pos_from_cursor_pos(textBox, std::max(
157 cursor->selectionBeginPos, cursor->selectionEndPos)),
158 inputType);
159 });
160 }
161
162 void startNetworkService() {
163 Logger::get().log(Logger::LogType::INFO, "[AndroidJNICalls::startNetworkService] Start service");

Callers 1

Calls 6

jni_local_frameFunction · 0.85
string2jstringFunction · 0.85
set_rich_text_dataMethod · 0.80
get_rich_text_dataMethod · 0.80
get_stringMethod · 0.45

Tested by

no test coverage detected