| 211 | } |
| 212 | |
| 213 | void updateTextboxAndCursorPos(CustomEvents::InputTextBoxID tId, const std::shared_ptr<RichText::TextBox>& newTextbox, const std::shared_ptr<RichText::TextBox::Cursor>& newCursor) { |
| 214 | std::scoped_lock a{textboxMutex}; |
| 215 | |
| 216 | if(tId == textboxID) { |
| 217 | *cursor = *newCursor; |
| 218 | textBox->set_rich_text_data(newTextbox->get_rich_text_data()); |
| 219 | |
| 220 | JNIEnv* env = static_cast<JNIEnv*>(SDL_GetAndroidJNIEnv()); |
| 221 | jni_local_frame(env, 16, [&] { |
| 222 | jobject activity = (jobject) SDL_GetAndroidActivity(); |
| 223 | jclass clazz = env->GetObjectClass(activity); |
| 224 | jmethodID method_id = env->GetStaticMethodID(clazz, "updateCursorPos", |
| 225 | "(II)V"); |
| 226 | env->CallStaticVoidMethod(clazz, method_id, |
| 227 | get_android_text_pos_from_cursor_pos(textBox, std::min( |
| 228 | cursor->selectionBeginPos, |
| 229 | cursor->selectionEndPos)), |
| 230 | get_android_text_pos_from_cursor_pos(textBox, std::max( |
| 231 | cursor->selectionBeginPos, |
| 232 | cursor->selectionEndPos))); |
| 233 | }); |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | std::pair<bool, bool> getChangesToCommit(CustomEvents::InputTextBoxID tId) { |
| 238 | std::scoped_lock a{textboxMutex}; |
no test coverage detected