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

Commit dc0a1b3

Browse files
committed
[[ Bug 21466 ]] Implement returnKeyType field property
This patch adds a new property to fields to control the style of the return button on soft keyboards on mobile.
1 parent f38ddf1 commit dc0a1b3

19 files changed

Lines changed: 233 additions & 93 deletions

docs/dictionary/command/mobileSetKeyboardReturnKey.lcdoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ being focused, simply use the commands in an <openField> handler of the
5454
given field. The keyboard is only shown after this handler returns, so
5555
it is the ideal time to configure it.
5656

57+
>**Note:** If a field has a non-empty <returnKeyType> that value will override
58+
> the the value set by <mobileSetKeyboardReturnKey>.
59+
5760
References: mobileSetKeyboardType (command),
5861
keyboardDeactivated (message), keyboardActivated (message),
59-
openField (message)
62+
openField (message), returnKeyType (property)
6063

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Name: returnKeyType
2+
3+
Type: property
4+
5+
Syntax: set the returnKeyType of <field> to <type>
6+
Syntax: get the returnKeyType of <field>
7+
8+
Summary:
9+
Configures the type of return key that is to be displayed on the keyboard.
10+
11+
Introduced: 9.5
12+
13+
Associations: field
14+
15+
OS: ios, android
16+
17+
Platforms: mobile
18+
19+
Example:
20+
set the returnKeyType of field "cost" to "go"
21+
22+
Example:
23+
set the returnKeyType of field "name" to empty
24+
25+
Parameters:
26+
type (enum):
27+
The type of return key to use. One of:
28+
29+
- "": use the global value from <mobileSetKeyboardReturnKey>
30+
- default: the normal return key
31+
- go: the 'Go' return key
32+
- google: the 'Google' return key (iOS only)
33+
- join: the 'Join' return key (iOS only)
34+
- next: the 'Next' return key
35+
- route: the 'Route' return key (iOS only)
36+
- search: the 'Search' return key
37+
- send: the 'Send' return key
38+
- yahoo: the 'Yahoo' return key (iOS only)
39+
- done: the 'Done' return key
40+
- emergency call: the 'emergency call' return key (iOS only)
41+
42+
Description:
43+
Use the <returnKeyType> command to configure the type of return key that is to be
44+
displayed for a field. If set to empty which is the default the type set by the
45+
<mobileSetKeyboardReturnKey> command is used to configure the type of return key
46+
that is to be displayed.
47+
48+
The return key type setting takes affect the next time the keyboard is
49+
shown. It does not affect the current keyboard, if it is being displayed.
50+
51+
References: mobileSetKeyboardReturnKey (command),
52+
keyboardDeactivated (message), keyboardActivated (message)
53+

docs/notes/bugfix-21466.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# New returnKeyType field property
2+
3+
A new property has been added to fields to control the return key type displayed
4+
on the mobile keyboard.

engine/src/exec-interface-field.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,31 @@ static MCExecEnumTypeInfo _kMCInterfaceKeyboardTypeTypeInfo =
124124

125125
MCExecEnumTypeInfo* kMCInterfaceKeyboardTypeTypeInfo = &_kMCInterfaceKeyboardTypeTypeInfo;
126126

127+
static MCExecEnumTypeElementInfo _kMCInterfaceReturnKeyTypeElementInfo[] =
128+
{
129+
{ "", kMCInterfaceReturnKeyTypeNone, false},
130+
{ "default", kMCInterfaceReturnKeyTypeDefault, false},
131+
{ "go", kMCInterfaceReturnKeyTypeGo, false},
132+
{ "google", kMCInterfaceReturnKeyTypeGoogle, false},
133+
{ "join", kMCInterfaceReturnKeyTypeJoin, false},
134+
{ "next", kMCInterfaceReturnKeyTypeNext, false},
135+
{ "route", kMCInterfaceReturnKeyTypeRoute, false},
136+
{ "search", kMCInterfaceReturnKeyTypeSearch, false},
137+
{ "send", kMCInterfaceReturnKeyTypeSend, false},
138+
{ "yahoo", kMCInterfaceReturnKeyTypeYahoo, false},
139+
{ "done", kMCInterfaceReturnKeyTypeDone, false},
140+
{ "emergency call", kMCInterfaceReturnKeyTypeEmergencyCall, false}
141+
};
142+
143+
static MCExecEnumTypeInfo _kMCInterfaceReturnKeyTypeTypeInfo =
144+
{
145+
"Interface.ReturnKeyType",
146+
sizeof(_kMCInterfaceReturnKeyTypeElementInfo) / sizeof(MCExecEnumTypeElementInfo),
147+
_kMCInterfaceReturnKeyTypeElementInfo
148+
};
149+
150+
MCExecEnumTypeInfo* kMCInterfaceReturnKeyTypeTypeInfo = &_kMCInterfaceReturnKeyTypeTypeInfo;
151+
127152
//////////
128153

129154
static void MCInterfaceFieldRangesParse(MCExecContext& ctxt, MCStringRef p_input, MCInterfaceFieldRanges& r_output)
@@ -1417,3 +1442,13 @@ void MCField::SetKeyboardType(MCExecContext& ctxt, intenum_t p_type)
14171442
{
14181443
keyboard_type = static_cast<MCInterfaceKeyboardType>(p_type);
14191444
}
1445+
1446+
void MCField::GetReturnKeyType(MCExecContext& ctxt, intenum_t& r_type)
1447+
{
1448+
r_type = static_cast<intenum_t>(return_key_type);
1449+
}
1450+
1451+
void MCField::SetReturnKeyType(MCExecContext& ctxt, intenum_t p_type)
1452+
{
1453+
return_key_type = static_cast<MCInterfaceReturnKeyType>(p_type);
1454+
}

engine/src/exec-interface.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,23 @@ enum MCInterfaceKeyboardType : unsigned
247247
kMCInterfaceKeyboardTypeContact
248248
};
249249

250+
251+
enum MCInterfaceReturnKeyType : unsigned
252+
{
253+
kMCInterfaceReturnKeyTypeNone,
254+
kMCInterfaceReturnKeyTypeDefault,
255+
kMCInterfaceReturnKeyTypeGo,
256+
kMCInterfaceReturnKeyTypeGoogle,
257+
kMCInterfaceReturnKeyTypeJoin,
258+
kMCInterfaceReturnKeyTypeNext,
259+
kMCInterfaceReturnKeyTypeRoute,
260+
kMCInterfaceReturnKeyTypeSearch,
261+
kMCInterfaceReturnKeyTypeSend,
262+
kMCInterfaceReturnKeyTypeYahoo,
263+
kMCInterfaceReturnKeyTypeDone,
264+
kMCInterfaceReturnKeyTypeEmergencyCall
265+
};
266+
250267
#endif // EXEC_INTERFACE_H
251268

252269
//////////

engine/src/exec-misc.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,30 +57,6 @@ static MCExecEnumTypeInfo _kMCMiscStatusBarStyleTypeInfo =
5757

5858
MCExecEnumTypeInfo* kMCMiscStatusBarStyleTypeInfo = &_kMCMiscStatusBarStyleTypeInfo;
5959

60-
static MCExecEnumTypeElementInfo _kMCMiscKeyboardReturnKeyElementInfo[] =
61-
{
62-
{ "default", kMCMiscKeyboardReturnKeyDefault, false},
63-
{ "go", kMCMiscKeyboardReturnKeyGo, false},
64-
{ "google", kMCMiscKeyboardReturnKeyGoogle, false},
65-
{ "join", kMCMiscKeyboardReturnKeyJoin, false},
66-
{ "next", kMCMiscKeyboardReturnKeyNext, false},
67-
{ "route", kMCMiscKeyboardReturnKeyRoute, false},
68-
{ "search", kMCMiscKeyboardReturnKeySearch, false},
69-
{ "send", kMCMiscKeyboardReturnKeySend, false},
70-
{ "yahoo", kMCMiscKeyboardReturnKeyYahoo, false},
71-
{ "done", kMCMiscKeyboardReturnKeyDone, false},
72-
{ "emergency call", kMCMiscKeyboardReturnKeyEmergencyCall, false}
73-
};
74-
75-
static MCExecEnumTypeInfo _kMCMiscKeyboardReturnKeyTypeInfo =
76-
{
77-
"Misc.KeyboardReturnKey",
78-
sizeof(_kMCMiscKeyboardReturnKeyElementInfo) / sizeof(MCExecEnumTypeElementInfo),
79-
_kMCMiscKeyboardReturnKeyElementInfo
80-
};
81-
82-
MCExecEnumTypeInfo* kMCMiscKeyboardReturnKeyTypeInfo = &_kMCMiscKeyboardReturnKeyTypeInfo;
83-
8460
////////////////////////////////////////////////////////////////////////////////
8561

8662
void MCMiscGetDeviceToken(MCExecContext& ctxt, MCStringRef& r_token)

engine/src/exec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2833,6 +2833,7 @@ extern MCExecEnumTypeInfo *kMCInterfaceFieldCursorMovementTypeInfo;
28332833
extern MCExecEnumTypeInfo *kMCInterfaceTextDirectionTypeInfo;
28342834
extern MCExecCustomTypeInfo *kMCInterfaceFieldTabAlignmentsTypeInfo;
28352835
extern MCExecEnumTypeInfo* kMCInterfaceKeyboardTypeTypeInfo;
2836+
extern MCExecEnumTypeInfo* kMCInterfaceReturnKeyTypeTypeInfo;
28362837

28372838
///////////
28382839

@@ -3997,7 +3998,6 @@ void MCSoundSetAudioCategory(MCExecContext &ctxt, intenum_t p_category);
39973998

39983999
/////////////
39994000

4000-
extern MCExecEnumTypeInfo* kMCMiscKeyboardReturnTypeTypeInfo;
40014001
extern MCExecEnumTypeInfo* kMCMiscStatusBarStyleTypeInfo;
40024002

40034003
void MCMiscGetDeviceToken(MCExecContext& ctxt, MCStringRef& r_token);

engine/src/field.cpp

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ MCPropertyInfo MCField::kProperties[] =
132132
DEFINE_RO_OBJ_CUSTOM_PROPERTY(P_PAGE_RANGES, InterfaceFieldRanges, MCField, PageRanges)
133133

134134
DEFINE_RW_OBJ_ENUM_PROPERTY(P_KEYBOARD_TYPE, InterfaceKeyboardType, MCField, KeyboardType)
135+
DEFINE_RW_OBJ_ENUM_PROPERTY(P_RETURN_KEY_TYPE, InterfaceReturnKeyType, MCField, ReturnKeyType)
135136

136137
DEFINE_RW_OBJ_NON_EFFECTIVE_OPTIONAL_ENUM_PROPERTY(P_TEXT_ALIGN, InterfaceTextAlign, MCField, TextAlign)
137138
DEFINE_RO_OBJ_EFFECTIVE_ENUM_PROPERTY(P_TEXT_ALIGN, InterfaceTextAlign, MCField, TextAlign)
@@ -261,6 +262,7 @@ MCField::MCField()
261262
m_recompute = false;
262263

263264
keyboard_type = kMCInterfaceKeyboardTypeNone;
265+
return_key_type = kMCInterfaceReturnKeyTypeNone;
264266
}
265267

266268
MCField::MCField(const MCField &fref) : MCControl(fref)
@@ -278,6 +280,7 @@ MCField::MCField(const MCField &fref) : MCControl(fref)
278280
cursor_movement = fref.cursor_movement;
279281
text_direction= fref.text_direction;
280282
keyboard_type = fref.keyboard_type;
283+
return_key_type = fref.return_key_type;
281284

282285
if (fref.vscrollbar != NULL)
283286
{
@@ -2567,6 +2570,7 @@ void MCField::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool p
25672570
// SN-2015-04-30: [[ Bug 15175 ]] TabAlignment flag added
25682571
#define FIELD_EXTRA_TABALIGN (1 << 1)
25692572
#define FIELD_EXTRA_KEYBOARDTYPE (1 << 2)
2573+
#define FIELD_EXTRA_RETURNKEYTYPE (1 << 3)
25702574

25712575
IO_stat MCField::extendedsave(MCObjectOutputStream& p_stream, uint4 p_part, uint32_t p_version)
25722576
{
@@ -2595,6 +2599,12 @@ IO_stat MCField::extendedsave(MCObjectOutputStream& p_stream, uint4 p_part, uint
25952599
t_flags |= FIELD_EXTRA_KEYBOARDTYPE;
25962600
t_size += sizeof(int8_t);
25972601
}
2602+
2603+
if (return_key_type != kMCInterfaceReturnKeyTypeNone)
2604+
{
2605+
t_flags |= FIELD_EXTRA_RETURNKEYTYPE;
2606+
t_size += sizeof(int8_t);
2607+
}
25982608

25992609
IO_stat t_stat;
26002610
t_stat = p_stream . WriteTag(t_flags, t_size);
@@ -2615,7 +2625,12 @@ IO_stat MCField::extendedsave(MCObjectOutputStream& p_stream, uint4 p_part, uint
26152625
t_stat = p_stream . WriteS8((int8_t)keyboard_type);
26162626
}
26172627

2618-
if (t_stat == IO_NORMAL)
2628+
if (t_stat == IO_NORMAL && (t_flags & FIELD_EXTRA_RETURNKEYTYPE))
2629+
{
2630+
t_stat = p_stream . WriteS8((int8_t)return_key_type);
2631+
}
2632+
2633+
if (t_stat == IO_NORMAL)
26192634
t_stat = MCObject::extendedsave(p_stream, p_part, p_version);
26202635

26212636
return t_stat;
@@ -2684,6 +2699,16 @@ IO_stat MCField::extendedload(MCObjectInputStream& p_stream, uint32_t p_version,
26842699
}
26852700
}
26862701

2702+
if (t_stat == IO_NORMAL && (t_flags & FIELD_EXTRA_RETURNKEYTYPE) != 0)
2703+
{
2704+
int8_t t_value;
2705+
t_stat = checkloadstat(p_stream . ReadS8(t_value));
2706+
if (t_stat == IO_NORMAL)
2707+
{
2708+
return_key_type = static_cast<MCInterfaceReturnKeyType>(t_value);
2709+
}
2710+
}
2711+
26872712
if (t_stat == IO_NORMAL)
26882713
t_stat = checkloadstat(p_stream . Skip(t_length));
26892714

@@ -2711,7 +2736,8 @@ IO_stat MCField::save(IO_handle stream, uint4 p_part, bool p_force_ext, uint32_t
27112736
bool t_has_extension;
27122737
t_has_extension = text_direction != kMCTextDirectionAuto ||
27132738
nalignments != 0 ||
2714-
keyboard_type != kMCInterfaceKeyboardTypeNone;
2739+
keyboard_type != kMCInterfaceKeyboardTypeNone ||
2740+
return_key_type != kMCInterfaceReturnKeyTypeNone;
27152741

27162742
if ((stat = MCObject::save(stream, p_part, t_has_extension || p_force_ext, p_version)) != IO_NORMAL)
27172743
return stat;

engine/src/field.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ class MCField : public MCControl, public MCMixinObjectHandle<MCField>
241241
MCTextDirection text_direction;
242242
MCInterfaceFieldCursorMovement cursor_movement;
243243
MCInterfaceKeyboardType keyboard_type : 4;
244+
MCInterfaceReturnKeyType return_key_type : 4;
244245

245246
// MM-2014-08-11: [[ Bug 13149 ]] Used to flag if a recompute is required during the next draw.
246247
bool m_recompute : 1;
@@ -612,6 +613,7 @@ class MCField : public MCControl, public MCMixinObjectHandle<MCField>
612613
MCRectangle firstRectForCharacterRange(int32_t& si, int32_t& ei);
613614

614615
MCInterfaceKeyboardType getkeyboardtype() { return keyboard_type; }
616+
MCInterfaceReturnKeyType getreturnkeytype() { return return_key_type; }
615617

616618
////////// BIDIRECTIONAL SUPPORT
617619

@@ -727,6 +729,8 @@ class MCField : public MCControl, public MCMixinObjectHandle<MCField>
727729

728730
void GetKeyboardType(MCExecContext& ctxt, intenum_t& r_type);
729731
void SetKeyboardType(MCExecContext& ctxt, intenum_t p_type);
732+
void GetReturnKeyType(MCExecContext& ctxt, intenum_t& r_type);
733+
void SetReturnKeyType(MCExecContext& ctxt, intenum_t p_type);
730734

731735
virtual void SetShadow(MCExecContext& ctxt, const MCInterfaceShadow& p_shadow);
732736
virtual void SetShowBorder(MCExecContext& ctxt, bool setting);

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public class Engine extends View implements EngineApi
115115
private int m_default_text_editor_mode;
116116

117117
private int m_default_ime_action;
118+
private int m_ime_action;
118119

119120
private SensorModule m_sensor_module;
120121
private DialogModule m_dialog_module;
@@ -170,6 +171,7 @@ public void handleMessage(Message p_message) {
170171
m_text_editor_visible = false;
171172

172173
m_default_ime_action = EditorInfo.IME_FLAG_NO_ENTER_ACTION | EditorInfo.IME_ACTION_DONE;
174+
m_ime_action = 0;
173175

174176
// initialise modules
175177
m_sensor_module = new SensorModule(this);
@@ -601,7 +603,15 @@ public boolean performEditorAction (int editorAction)
601603

602604
outAttrs.actionLabel = null;
603605
outAttrs.inputType = t_type;
604-
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI | m_default_ime_action;
606+
607+
if (m_ime_action != 0)
608+
{
609+
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI | m_ime_action;
610+
}
611+
else
612+
{
613+
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI | m_default_ime_action;
614+
}
605615

606616
return t_connection;
607617
}
@@ -677,7 +687,7 @@ public void resetKeyboard()
677687
imm.restartInput(this);
678688
}
679689

680-
public void setTextInputVisible(boolean p_visible, int p_input_mode)
690+
public void setTextInputVisible(boolean p_visible, int p_input_mode, int p_ime_action)
681691
{
682692
m_text_editor_visible = p_visible;
683693

@@ -687,12 +697,14 @@ public void setTextInputVisible(boolean p_visible, int p_input_mode)
687697
if (p_visible)
688698
{
689699
m_text_editor_mode = p_input_mode;
700+
m_ime_action = p_ime_action;
690701
showKeyboard();
691702
}
692703
else
693704
{
694705
hideKeyboard();
695706
m_text_editor_mode = 0;
707+
m_ime_action = 0;
696708
}
697709
}
698710

0 commit comments

Comments
 (0)