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

Commit a083fb6

Browse files
committed
[[ Bug 22840 ]] Activate IME in redraw
This patch moves IME activation to screen redraw. This has the benefit of limiting repeated IME activation/deactivation when setting field properties. It additionally allows `lock screen` to be used to control IME activation.
1 parent 7f7ae46 commit a083fb6

17 files changed

+38
-54
lines changed

docs/notes/bugfix-22840.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Improved IME activation
2+
3+
The IME (soft keyboard on mobile) is now activated and deactivated if required
4+
only on redraw. The change allows `lock screen` to delay changes to the IME.

engine/src/card.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
6666

6767
#include "stackfileformat.h"
6868

69+
#include "mode.h"
70+
6971
MCRectangle MCCard::selrect;
7072
int2 MCCard::startx;
7173
int2 MCCard::starty;
@@ -804,7 +806,7 @@ Boolean MCCard::mdown(uint2 which)
804806
#ifdef _MOBILE
805807
// Make sure the IME has gone away on mobile if due to an explicit card
806808
// click.
807-
MCscreen -> closeIME();
809+
MCModeActivateIme(getstack(), false);
808810
#endif
809811
message_with_valueref_args(MCM_mouse_down, MCSTR("1"));
810812
if (!(MCbuttonstate & (0x1L << (which - 1))))

engine/src/desktop-dc.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -926,10 +926,6 @@ void MCScreenDC::clearIME(Window w)
926926
MCPlatformResetTextInputInWindow(MCactivefield -> getstack() -> getwindow());
927927
}
928928

929-
void MCScreenDC::openIME()
930-
{
931-
}
932-
933929
void MCScreenDC::activateIME(Boolean activate)
934930
{
935931
if (!MCactivefield)
@@ -938,10 +934,6 @@ void MCScreenDC::activateIME(Boolean activate)
938934
MCPlatformConfigureTextInputInWindow(MCactivefield -> getstack() -> getwindow(), activate);
939935
}
940936

941-
void MCScreenDC::closeIME()
942-
{
943-
}
944-
945937
////////////////////////////////////////////////////////////////////////////////
946938

947939
void MCScreenDC::getsystemappearance(MCSystemAppearance &r_appearance)

engine/src/desktop-dc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ class MCScreenDC: public MCUIDC
109109
virtual void flushevents(uint2 e);
110110

111111
virtual void clearIME(Window w);
112-
virtual void openIME();
113112
virtual void activateIME(Boolean activate);
114-
virtual void closeIME();
115113

116114
virtual void seticon(uint4 p_icon);
117115
virtual void seticonmenu(MCStringRef p_menu);

engine/src/exec-interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ void MCInterfaceExecFocusOnNothing(MCExecContext &ctxt)
12941294
MCfocusedstackptr -> getcard() -> kunfocus();
12951295
#ifdef _MOBILE
12961296
// Make sure the IME is forced closed if explicitly asked to be.
1297-
MCscreen -> closeIME();
1297+
MCModeActivateIme(ctxt.GetObject() -> getstack(), false);
12981298
#endif
12991299
}
13001300

engine/src/lnxdc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,7 @@ class MCScreenDC : public MCUIDC
352352
virtual void clearIME(Window w);
353353
virtual void configureIME(int32_t x, int32_t y);
354354
virtual void activateIME(Boolean activate);
355-
//virtual void closeIME();
356-
355+
357356
virtual bool loadfont(MCStringRef p_path, bool p_globally, void*& r_loaded_font_handle);
358357
virtual bool unloadfont(MCStringRef p_path, bool p_globally, void *r_loaded_font_handle);
359358

engine/src/mblandroiddc.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -639,10 +639,6 @@ void MCScreenDC::pingwait(void)
639639

640640
////////////////////////////////////////////////////////////////////////////////
641641

642-
void MCScreenDC::openIME()
643-
{
644-
}
645-
646642
extern int32_t MCInterfaceAndroidKeyboardEnumFromMCExecEnum(MCInterfaceKeyboardType p_type);
647643
extern int32_t MCInterfaceAndroidReturnKeyTypeEnumFromMCExecEnum(MCInterfaceReturnKeyType p_type);
648644
void MCScreenDC::activateIME(Boolean activate)
@@ -672,10 +668,6 @@ void MCScreenDC::activateIME(Boolean activate)
672668
MCAndroidEngineRemoteCall("setTextInputVisible", "vbii", nil, activate, t_keyboard_type, t_return_key_type);
673669
}
674670

675-
void MCScreenDC::closeIME()
676-
{
677-
}
678-
679671
////////////////////////////////////////////////////////////////////////////////
680672

681673
void MCScreenDC::do_take_focus(void)

engine/src/mbldc.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,8 @@ class MCScreenDC: public MCUIDC
169169
// char *charsettofontname(uint1 charset, const char *oldfontname);
170170

171171
void clearIME(Window w);
172-
void openIME();
173172
void activateIME(Boolean activate);
174-
void closeIME();
175-
173+
176174
void enactraisewindows(void);
177175

178176
//

engine/src/mbliphonedc.mm

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -784,10 +784,6 @@ static void MCScreenDCDoSnapshot(void *p_env)
784784
MCIPhoneBreakWait();
785785
}
786786

787-
void MCScreenDC::openIME()
788-
{
789-
}
790-
791787
void MCScreenDC::activateIME(Boolean activate)
792788
{
793789
// MW-2012-08-06: [[ Fibers ]] Execute the system code on the main fiber.
@@ -799,14 +795,6 @@ static void MCScreenDCDoSnapshot(void *p_env)
799795
});
800796
}
801797

802-
void MCScreenDC::closeIME()
803-
{
804-
// MW-2012-08-06: [[ Fibers ]] Execute the system code on the main fiber.
805-
MCIPhoneRunBlockOnMainFiber(^(void) {
806-
MCIPhoneDeactivateKeyboard();
807-
});
808-
}
809-
810798
void MCScreenDC::do_take_focus(void)
811799
{
812800
// MW-2012-08-06: [[ Fibers ]] Execute the system code on the main fiber.

engine/src/mode_development.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ bool MCModeMakeLocalWindows(void)
672672

673673
void MCModeActivateIme(MCStack *p_stack, bool p_activate)
674674
{
675-
MCscreen -> activateIME(p_activate);
675+
MCscreen -> pendingIME(p_activate);
676676
}
677677

678678
void MCModeConfigureIme(MCStack *p_stack, bool p_enabled, int32_t x, int32_t y)

0 commit comments

Comments
 (0)