Skip to content

Commit e814677

Browse files
committed
[[ Bug 21464 ]] Implement mobileSetKeyboardReturnType
This patch implements `mobileSetKeyboardReturnType` for android and documents `iphoneSetKeyboardReturnType` as a synonym.
1 parent 426697f commit e814677

File tree

7 files changed

+64
-17
lines changed

7 files changed

+64
-17
lines changed

docs/dictionary/command/iphoneSetKeyboardReturnKey.lcdoc renamed to docs/dictionary/command/mobileSetKeyboardReturnKey.lcdoc

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,50 @@
1-
Name: iphoneSetKeyboardReturnKey
1+
Name: mobileSetKeyboardReturnKey
2+
3+
Synonyms: iphoneSetKeyboardReturnKey
24

35
Type: command
46

5-
Syntax: iphoneSetKeyboardReturnKey <returnKey>
7+
Syntax: mobileSetKeyboardReturnKey <returnKey>
68

79
Summary:
810
Configures the type of return key displayed on the keyboard.
911

1012
Introduced: 4.5.3
1113

12-
OS: ios
14+
Changes: LiveCode 9.5 added support for android
15+
16+
OS: ios, android
1317

1418
Platforms: mobile
1519

1620
Example:
17-
iphoneSetKeyboardReturnKey "alphabet"
21+
mobileSetKeyboardReturnKey "alphabet"
1822

1923
Example:
20-
iphoneSetKeyboardReturnKey "numeric"
24+
mobileSetKeyboardReturnKey "numeric"
2125

2226
Parameters:
2327
returnKey (enum):
2428
Specifies what the return key function is.
2529

2630
- default: the normal return key
2731
- go: the 'Go' return key
28-
- google: the 'Google' return key
29-
- join: the 'Join' return key
32+
- google: the 'Google' return key (iOS only)
33+
- join: the 'Join' return key (iOS only)
3034
- next: the 'Next' return key
31-
- route: the 'Route' return key
35+
- route: the 'Route' return key (iOS only)
3236
- search: the 'Search' return key
3337
- send: the 'Send' return key
34-
- yahoo: the 'Yahoo' return key
38+
- yahoo: the 'Yahoo' return key (iOS only)
3539
- done: the 'Done' return key
36-
- emergency call: the 'emergency call' return key
40+
- emergency call: the 'emergency call' return key (iOS only)
3741

3842

3943
Description:
40-
Use the iphoneSetKeyboardReturnKey command to configure the type of
44+
Use the mobileSetKeyboardReturnKey command to configure the type of
4145
return key displayed on the keyboard.
4246

43-
The <iphoneSetKeyboardReturnKey> command configures the type of return
47+
The <mobileSetKeyboardReturnKey> command configures the type of return
4448
key displayed on the keyboard
4549

4650
The return key type setting takes effect the next time the keyboard is

docs/dictionary/command/mobileSetKeyboardType.lcdoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ The keyboard type setting takes affect the next time the keyboard is
4444
shown. It does not affect the current keyboard, if it is being
4545
displayed.
4646

47-
References: iphoneSetKeyboardReturnKey (command),
47+
References: mobileSetKeyboardReturnKey (command),
4848
keyboardDeactivated (message), keyboardActivated (message)
4949

docs/dictionary/message/keyboardActivated.lcdoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ display layout to take account of the restricted screen area that is
2525
available.
2626

2727
References: mobileSetKeyboardType (command),
28-
iphoneSetKeyboardReturnKey (command), current card (glossary),
28+
mobileSetKeyboardReturnKey (command), current card (glossary),
2929
keyboardDeactivated (message)
3030

docs/dictionary/message/keyboardDeactivated.lcdoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ display layout to take account of the restricted screen area that
2525
becomes available when the keyboard is hidden.
2626

2727
References: mobileSetKeyboardType (command),
28-
iphoneSetKeyboardReturnKey (command), current card (glossary),
28+
mobileSetKeyboardReturnKey (command), current card (glossary),
2929
keyboardActivated (message)
3030

docs/notes/bugfix-21464.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# mobileSetKeyboardReturnKey on android
2+
3+
The mobileSetKeyboardReturnKey is now supported on android and the iphoneSetKeyboardReturnKey
4+
synonym is now deprecated

engine/src/java/com/runrev/android/Engine.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ public class Engine extends View implements EngineApi
113113
private boolean m_text_editor_visible;
114114
private int m_text_editor_mode;
115115

116+
private int m_default_ime_action;
117+
116118
private SensorModule m_sensor_module;
117119
private DialogModule m_dialog_module;
118120
private NetworkModule m_network_module;
@@ -165,6 +167,8 @@ public void handleMessage(Message p_message) {
165167
m_text_editor_mode = 1;
166168
m_text_editor_visible = false;
167169

170+
m_default_ime_action = EditorInfo.IME_FLAG_NO_ENTER_ACTION | EditorInfo.IME_ACTION_DONE;
171+
168172
// initialise modules
169173
m_sensor_module = new SensorModule(this);
170174
m_dialog_module = new DialogModule(this);
@@ -583,13 +587,19 @@ public boolean setComposingText(CharSequence text, int newCursorPosition)
583587
updateComposingText(text);
584588
return super.setComposingText(text, newCursorPosition);
585589
}
590+
@Override
591+
public boolean performEditorAction (int editorAction)
592+
{
593+
handleKey(0, 10);
594+
return true;
595+
}
586596
};
587597

588598
int t_type = getInputType(false);
589599

590600
outAttrs.actionLabel = null;
591601
outAttrs.inputType = t_type;
592-
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_FLAG_NO_ENTER_ACTION | EditorInfo.IME_ACTION_DONE;
602+
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI | m_default_ime_action;
593603

594604
return t_connection;
595605
}
@@ -677,6 +687,11 @@ public void setTextInputVisible(boolean p_visible)
677687
else
678688
hideKeyboard();
679689
}
690+
691+
public void setKeyboardReturnKey(int p_ime_action)
692+
{
693+
m_default_ime_action = p_ime_action;
694+
}
680695

681696
public void setTextInputMode(int p_mode)
682697
{

engine/src/mblandroidmisc.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,33 @@ bool MCSystemGetReachabilityTarget(MCStringRef& r_target)
702702
return false;
703703
}
704704

705+
static int32_t MCMiscGetAndroidReturnKeyTypeFromMCExecEnum(MCMiscKeyboardReturnKey p_type)
706+
{
707+
switch(p_type)
708+
{
709+
case kMCMiscKeyboardReturnKeyGo:
710+
return 0x2; // IME_ACTION_GO
711+
case kMCMiscKeyboardReturnKeyNext:
712+
return 0x5; // IME_ACTION_NEXT
713+
case kMCMiscKeyboardReturnKeySearch:
714+
return 0x3; // IME_ACTION_SEARCH
715+
case kMCMiscKeyboardReturnKeySend:
716+
return 0x4; // IME_ACTION_SEND
717+
case kMCMiscKeyboardReturnKeyDone:
718+
return 0x6; // IME_ACTION_DONE
719+
case kMCMiscKeyboardReturnKeyDefault:
720+
return 0x40000000 | 0x6; // IME_FLAG_NO_ENTER_ACTION | IME_ACTION_DONE
721+
default:
722+
return 0x0; // IME_ACTION_UNSPECIFIED
723+
}
724+
}
725+
705726
bool MCSystemSetKeyboardReturnKey(intenum_t p_type)
706727
{
707-
return false;
728+
int32_t t_type = MCMiscGetAndroidReturnKeyTypeFromMCExecEnum(static_cast<MCMiscKeyboardReturnKey>(p_type));
729+
MCAndroidEngineRemoteCall("setKeyboardReturnKey", "vi", nullptr, t_type);
730+
731+
return true;
708732
}
709733

710734

0 commit comments

Comments
 (0)