Skip to content

Commit b02b245

Browse files
seungsoo47bwikbs
authored andcommitted
Enable IMF on Webview (#17)
1 parent 571fa4a commit b02b245

File tree

5 files changed

+50
-6
lines changed

5 files changed

+50
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
</head>
5+
6+
<body>
7+
<input id="ip1" type="text" ></input>
8+
<button onclick="a()">Click</button>
9+
<input id="ip2" type="text" ></input>
10+
</body>
11+
<script>
12+
function a() {
13+
console.log("Hello: " + document.getElementById("ip1").value);
14+
}
15+
</script>
16+
</html>

packages/webview_flutter/lib/webview_flutter_tizen.dart

+5-6
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,10 @@ class TizenViewController extends PlatformViewController {
7878

7979
int _textureId;
8080

81-
@override
8281
int get textureId => _textureId;
8382

8483
Size _size;
8584

86-
@override
8785
Future<void> setSize(Size size) async {
8886
assert(_state != _TizenViewState.disposed,
8987
'trying to size a disposed Tizen View. View id: $viewId');
@@ -103,7 +101,6 @@ class TizenViewController extends PlatformViewController {
103101
});
104102
}
105103

106-
@override
107104
Future<void> _sendCreateMessage() async {
108105
assert(!_size.isEmpty,
109106
'trying to create $TizenViewController without setting a valid size.');
@@ -128,7 +125,6 @@ class TizenViewController extends PlatformViewController {
128125
await SystemChannels.platform_views.invokeMethod<int>('create', args);
129126
}
130127

131-
@override
132128
Future<void> _sendDisposeMessage() {
133129
return SystemChannels.platform_views
134130
.invokeMethod<void>('dispose', <String, dynamic>{
@@ -205,8 +201,8 @@ class TizenViewController extends PlatformViewController {
205201
}
206202
await SystemChannels.platform_views
207203
.invokeMethod<dynamic>('touch', <String, dynamic>{
208-
"id": viewId,
209-
"event": [
204+
'id': viewId,
205+
'event': <dynamic>[
210206
eventType, // int, pointer event type
211207
event.buttons, // int, mouse button type (left, right, middle)
212208
event.localPosition.dx, // double, global position x
@@ -222,6 +218,7 @@ class TizenViewController extends PlatformViewController {
222218
if (_state != _TizenViewState.created) {
223219
return Future<void>.value();
224220
}
221+
// print('clearFocus : $viewId');
225222
return SystemChannels.platform_views
226223
.invokeMethod<void>('clearFocus', viewId);
227224
}
@@ -628,6 +625,7 @@ class _TizenWebViewState extends State<TizenWebView_> {
628625

629626
@override
630627
void didUpdateWidget(TizenWebView_ oldWidget) {
628+
// print('webview: didUpdateWidget()');
631629
super.didUpdateWidget(oldWidget);
632630

633631
final TextDirection newLayoutDirection = _findLayoutDirection();
@@ -688,6 +686,7 @@ class _TizenWebViewState extends State<TizenWebView_> {
688686
});
689687
return;
690688
}
689+
// print('_onFocusChange - viewId : $_id');
691690
SystemChannels.textInput
692691
.invokeMethod<void>(
693692
'TextInput.setPlatformViewClient',
Binary file not shown.

packages/webview_flutter/tizen/src/webview.cc

+25
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,31 @@ void WebView::DispatchKeyUpEvent(Ecore_Event_Key* keyEvent) {
435435
p);
436436
}
437437

438+
void WebView::SetSoftwareKeyboardContext(Ecore_IMF_Context* context) {
439+
webViewInstance_->RegisterOnShowSoftwareKeyboardIfPossibleHandler(
440+
[context](LWE::WebContainer* v) {
441+
LOG_DEBUG("WebView - Show Keyboard()\n");
442+
if (!context) {
443+
LOG_ERROR("Ecore_IMF_Context NULL\n");
444+
return;
445+
}
446+
ecore_imf_context_input_panel_show(context);
447+
ecore_imf_context_focus_in(context);
448+
});
449+
450+
webViewInstance_->RegisterOnHideSoftwareKeyboardIfPossibleHandler(
451+
[context](LWE::WebContainer*) {
452+
LOG_INFO("WebView - Hide Keyboard()\n");
453+
if (!context) {
454+
LOG_INFO("Ecore_IMF_Context NULL\n");
455+
return;
456+
}
457+
ecore_imf_context_reset(context);
458+
ecore_imf_context_focus_out(context);
459+
ecore_imf_context_input_panel_hide(context);
460+
});
461+
}
462+
438463
void WebView::ClearFocus() { LOG_DEBUG("WebView::clearFocus \n"); }
439464

440465
void WebView::SetDirection(int direction) {

packages/webview_flutter/tizen/src/webview.h

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace LWE {
1111
class WebContainer;
1212
}
1313

14+
class TextInputChannel;
15+
1416
class WebView : public PlatformView {
1517
public:
1618
WebView(flutter::PluginRegistrar* registrar, int viewId,
@@ -28,6 +30,8 @@ class WebView : public PlatformView {
2830
virtual void DispatchKeyDownEvent(Ecore_Event_Key* key) override;
2931
virtual void DispatchKeyUpEvent(Ecore_Event_Key* key) override;
3032

33+
virtual void SetSoftwareKeyboardContext(Ecore_IMF_Context* context) override;
34+
3135
private:
3236
void HandleMethodCall(
3337
const flutter::MethodCall<flutter::EncodableValue>& method_call,

0 commit comments

Comments
 (0)