mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Adding keyboard service.
This allows to show the soft keyboard on Android. Also updated platform_viewport_android to dispatch key events. R=abarth@chromium.org BUG=449002 Review URL: https://codereview.chromium.org/856063002
This commit is contained in:
parent
c0c8a41eb3
commit
69be2dee41
@ -23,6 +23,7 @@ source_set("libraries") {
|
||||
"//mojo/public/cpp/system",
|
||||
"//mojo/public/cpp/utility",
|
||||
"//mojo/public/interfaces/application",
|
||||
"//mojo/services/keyboard/public/interfaces",
|
||||
"//mojo/services/navigation/public/interfaces",
|
||||
"//mojo/services/view_manager/public/cpp",
|
||||
"//skia",
|
||||
|
||||
@ -3,7 +3,9 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
-->
|
||||
<import src="/sky/framework/shell.sky" as="shell" />
|
||||
<import src="/sky/framework/sky-element/sky-element.sky" as="SkyElement" />
|
||||
<import src="/mojo/services/keyboard/public/interfaces/keyboard.mojom.sky" as="keyboard" />
|
||||
|
||||
<sky-element name="sky-input" attributes="value:string">
|
||||
<template>
|
||||
@ -22,9 +24,13 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
<div id="control" contenteditable on-keydown="handleKeyDown">{{ value }}</div>
|
||||
<div id="control" contenteditable
|
||||
on-focus="handleFocus"
|
||||
on-blur="handleBlur"
|
||||
on-keydown="handleKeyDown">{{ value }}</div>
|
||||
</template>
|
||||
<script>
|
||||
var keyboard = shell.connectToService("mojo:keyboard", keyboard.Keyboard);
|
||||
module.exports = class extends SkyElement {
|
||||
shadowRootReady() {
|
||||
var control = this.shadowRoot.getElementById('control');
|
||||
@ -54,6 +60,12 @@ module.exports = class extends SkyElement {
|
||||
if (event.keyCode == 0xD)
|
||||
event.preventDefault();
|
||||
}
|
||||
handleFocus(event) {
|
||||
keyboard.show();
|
||||
}
|
||||
handleBlur(event) {
|
||||
keyboard.hide();
|
||||
}
|
||||
}.register();
|
||||
</script>
|
||||
</sky-element>
|
||||
|
||||
@ -126,6 +126,8 @@ void DocumentView::OnEmbed(
|
||||
// TODO(abarth): We should ask the view whether it is focused instead of
|
||||
// assuming that we're focused.
|
||||
web_view_->setFocus(true);
|
||||
// Needed on android, as the window does not get the focus otherwise.
|
||||
root_->SetFocus();
|
||||
root_->AddObserver(this);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user