Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit f7fc3dc

Browse files
committed
[Bug 17361] Ensure <mobileControlDo "myInput", "focus"> works on Android
1 parent 0784d59 commit f7fc3dc

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

docs/notes/bugfix-17361.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Ensure `mobileControlDo "myinput", "focus"` works on Android

engine/src/java/com/runrev/android/nativecontrol/InputControl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,14 @@ public int getSelectedRangeLength()
315315
public void focusControl()
316316
{
317317
m_text_view.requestFocus();
318+
319+
InputMethodManager imm;
320+
imm = (InputMethodManager) m_text_view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
321+
322+
if (imm != null)
323+
imm.restartInput(m_text_view);
324+
325+
imm.showSoftInput(m_text_view, InputMethodManager.SHOW_IMPLICIT);
318326
}
319327

320328
public native void doBeginEditing();

engine/src/mblandroidinput.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,14 @@ MCObjectPropertyTable MCAndroidInputControl::kPropertyTable =
285285

286286
MCNativeControlActionInfo MCAndroidInputControl::kActions[] =
287287
{
288+
DEFINE_CTRL_EXEC_METHOD(Focus, Void, MCAndroidInputControl, Focus)
288289
};
289290

290291
MCNativeControlActionTable MCAndroidInputControl::kActionTable =
291292
{
292293
&MCAndroidControl::kActionTable,
293-
0,
294-
nil,
294+
sizeof(kActions) / sizeof(kActions[0]),
295+
&kActions[0],
295296
};
296297

297298
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)