Skip to content

Commit c56a77e

Browse files
committed
k
1 parent a07e707 commit c56a77e

1 file changed

Lines changed: 18 additions & 12 deletions

File tree

src/backend.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void DevTools::render(GLRenderCtx* ctx) {
127127
this->renderDrawData(ImGui::GetDrawData());
128128

129129
// ime fuckery for mobile
130-
if (GEODE_DESKTOP(false and) true) if (ImGui::IsMouseReleased(0)) {
130+
/*if (GEODE_DESKTOP(false and) true)*/ if (ImGui::IsMouseReleased(0)) {
131131
static Ref<TextInput> inpNodeRef;
132132
if (!inpNodeRef) {
133133
inpNodeRef = TextInput::create(100.f, "xd", "geode.loader/mdFont.fnt");
@@ -157,34 +157,38 @@ void DevTools::render(GLRenderCtx* ctx) {
157157
log::info("Created text input node for ImGui: {}", inpNodeRef);
158158
}
159159
if (inpNodeRef) {
160-
if (ImGui::GetIO().WantTextInput) {
160+
if (ImGui::GetIO().WantTextInput) queueInMainThread([]{
161161
ImGuiInputTextState& State = GImGui->InputTextState;
162162
static int imguicurpos_onclick;
163163
imguicurpos_onclick = State.GetCursorPos();
164164

165165
if (State.TextLen) {
166166
inpNodeRef->setString(std::string(State.TextA.Data, State.TextLen));
167167

168-
inpNodeRef->focus();
169-
inpNodeRef->getInputNode()->onClickTrackNode(true);
170-
168+
#ifndef GEODE_IS_IOS // CCIMEDispatcher::sharedDispatcher() = imac 0x4a89a0, m1 0x411d04;
171169
for (auto c : inpNodeRef->getString()) {
172170
CCIMEDispatcher::sharedDispatcher()->dispatchInsertText("a", 1, KEY_Left);
173171
}
174172
for (auto c = 0; c < imguicurpos_onclick; ++c) {
175173
CCIMEDispatcher::sharedDispatcher()->dispatchInsertText("a", 1, KEY_Right);
176174
}
175+
#else
176+
inpNodeRef->setString("");
177+
#endif
178+
179+
inpNodeRef->focus();
180+
inpNodeRef->getInputNode()->onClickTrackNode(true);
177181

178-
//inpNodeRef->setPosition(CCScene::get()->getContentSize() / 2.f);
179-
//inpNodeRef->removeFromParentAndCleanup(false);
180-
//CCScene::get()->addChild(inpNodeRef);
182+
inpNodeRef->setPosition(CCScene::get()->getContentSize() / 2.f);
183+
inpNodeRef->removeFromParentAndCleanup(false);
184+
CCScene::get()->addChild(inpNodeRef);
181185
}
182-
}
186+
});
183187
else {
184188
inpNodeRef->defocus();
185189
inpNodeRef->getInputNode()->onClickTrackNode(false);
186190
}
187-
};
191+
}
188192
}
189193

190194
// Cursor updates via winapi
@@ -463,14 +467,16 @@ class $modify(CCIMEDispatcher) {
463467
if (0) log::debug("{}(text = \"{}\", len = {}, KEY_{} = {})", __FUNCTION__,
464468
text, len, key > 1 ? CCKeyboardDispatcher::get()->keyToString(key) : "KEY_Unknown", (int)key
465469
);
466-
CCIMEDispatcher::dispatchInsertText(text, len, key);
467470
if (key < 0) { // KEY_Unknown, -1
468471
ImGui::GetIO().AddInputCharactersUTF8(std::string(text, len).c_str());
469472
}
470-
else { // KEY_... (text "a")
473+
else if (ImGui::GetIO().WantCaptureKeyboard) { // KEY_... (text "a")
474+
auto* capt = &ImGui::GetIO().WantCaptureKeyboard;
475+
capt = ImGui::GetIO().WantTextInput ? false : capt;
471476
CCKeyboardDispatcher::get()->dispatchKeyboardMSG(key, true, false);
472477
CCKeyboardDispatcher::get()->dispatchKeyboardMSG(key, false, false);
473478
}
479+
CCIMEDispatcher::dispatchInsertText(text, len, key);
474480
}
475481
};
476482

0 commit comments

Comments
 (0)