From ed799a41d639fe2fd4da86367558cdde18a84013 Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Fri, 19 Apr 2024 18:14:32 +0200 Subject: [PATCH 1/6] Sending KeyEvents from IME --- .../demo/textfield/KeyboardActionsExample.kt | 3 +- .../compose/ui/input/key/KeyEvent.web.kt | 2 +- .../compose/ui/platform/BackingTextArea.kt | 120 +++++++++++------- .../compose/ui/platform/WebImeInputService.kt | 4 +- .../ui/platform/WebTextInputService.kt | 3 +- .../compose/ui/window/ComposeWindow.web.kt | 5 + 6 files changed, 89 insertions(+), 48 deletions(-) diff --git a/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/textfield/KeyboardActionsExample.kt b/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/textfield/KeyboardActionsExample.kt index de6c5192243d9..6eb1a5e8eb7a3 100644 --- a/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/textfield/KeyboardActionsExample.kt +++ b/compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/textfield/KeyboardActionsExample.kt @@ -27,6 +27,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier +import androidx.compose.ui.input.key.onKeyEvent import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight @@ -108,7 +109,7 @@ private fun TextBlock( OutlinedTextField( value = textState.value, onValueChange = { textState.value = it }, - modifier = Modifier.fillMaxWidth().padding(top = 8.dp), + modifier = Modifier.fillMaxWidth().padding(top = 8.dp).onKeyEvent { println("KEY EVENT $this"); false }, textStyle = TextStyle(fontSize = 12.sp, fontWeight = FontWeight.Normal), keyboardOptions = KeyboardOptions(imeAction = imeActionName), keyboardActions = keyboardActions diff --git a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/input/key/KeyEvent.web.kt b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/input/key/KeyEvent.web.kt index 6012269cef4e8..42e1d1920942a 100644 --- a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/input/key/KeyEvent.web.kt +++ b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/input/key/KeyEvent.web.kt @@ -46,7 +46,7 @@ internal fun KeyboardEvent.toComposeEvent(): KeyEvent { nativeKeyEvent = InternalKeyEvent( key = Key(keyCode.toLong(), location), type = when (type) { - "keydown", "keypress" -> KeyEventType.KeyDown + "keydown" -> KeyEventType.KeyDown "keyup" -> KeyEventType.KeyUp else -> KeyEventType.Unknown }, diff --git a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/BackingTextArea.kt b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/BackingTextArea.kt index 997e215f4d60e..34024bbe80688 100644 --- a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/BackingTextArea.kt +++ b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/BackingTextArea.kt @@ -17,6 +17,8 @@ package androidx.compose.ui.platform import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.input.key.KeyEvent +import androidx.compose.ui.input.key.toComposeEvent import androidx.compose.ui.text.input.CommitTextCommand import androidx.compose.ui.text.input.DeleteAllCommand import androidx.compose.ui.text.input.EditCommand @@ -27,6 +29,7 @@ import androidx.compose.ui.text.input.TextFieldValue import kotlinx.browser.document import org.w3c.dom.HTMLTextAreaElement import org.w3c.dom.events.KeyboardEvent +import org.w3c.dom.events.KeyboardEventInit /** * The purpose of this entity is to isolate synchronization between a TextFieldValue @@ -36,7 +39,8 @@ import org.w3c.dom.events.KeyboardEvent internal class BackingTextArea( private val imeOptions: ImeOptions, private val onEditCommand: (List) -> Unit, - private val onImeActionPerformed: (ImeAction) -> Unit + private val onImeActionPerformed: (ImeAction) -> Unit, + private val sendKey: (evt: KeyEvent) -> Unit ) { private val textArea: HTMLTextAreaElement = createHtmlInput() @@ -95,10 +99,23 @@ internal class BackingTextArea( setProperty("text-shadow", "none") } - htmlInput.addEventListener("input", { - val text = htmlInput.value - val cursorPosition = htmlInput.selectionEnd - sendImeValueToCompose(onEditCommand, text, cursorPosition) + htmlInput.addEventListener("input", { evt -> + evt.preventDefault() + evt as InputEventExtended + val data = evt.data + + if (evt.inputType == "insertLineBreak") { + if (imeOptions.singleLine) { + onImeActionPerformed(imeOptions.imeAction) + } + } else if ((data != null) && (data.length > 1)) { + sendImeValueToCompose(data) + } else { + val keyboardEvent = evt.toKeyboardEvent()?.toComposeEvent() + if (keyboardEvent != null) { + sendKey(keyboardEvent) + } + } }) htmlInput.addEventListener("contextmenu", { evt -> @@ -106,17 +123,6 @@ internal class BackingTextArea( evt.stopPropagation() }) - // this done by analogy with KeyCommand.NEW_LINE processing in TextFieldKeyInput - if (imeOptions.singleLine) { - htmlInput.addEventListener("keydown", { evt -> - evt.preventDefault() - evt as KeyboardEvent - if (evt.key == "Enter" && evt.type == "keydown") { - onImeActionPerformed(imeOptions.imeAction) - } - }) - } - return htmlInput } @@ -124,33 +130,6 @@ internal class BackingTextArea( document.body?.appendChild(textArea) } - private fun sendImeValueToCompose( - onEditCommand: (List) -> Unit, - text: String, - newCursorPosition: Int? = null - ) { - val value = if (text == "\n") { - "" - } else { - text - } - - if (newCursorPosition != null) { - onEditCommand( - listOf( - DeleteAllCommand(), - CommitTextCommand(value, newCursorPosition), - ) - ) - } else { - onEditCommand( - listOf( - CommitTextCommand(value, 1) - ) - ) - } - } - fun focus() { textArea.focus() } @@ -171,7 +150,60 @@ internal class BackingTextArea( textArea.setSelectionRange(textFieldValue.selection.start, textFieldValue.selection.end) } + private fun sendImeValueToCompose( + text: String, + newCursorPosition: Int? = null + ) { + if (newCursorPosition != null) { + onEditCommand( + listOf( + DeleteAllCommand(), + CommitTextCommand(text, newCursorPosition), + ) + ) + } else { + onEditCommand( + listOf( + CommitTextCommand(text, 1) + ) + ) + } + } + + fun dispose() { textArea.remove() } -} \ No newline at end of file +} + +private external interface InputEventExtended { + val inputType: String + val data: String? +} + +// TODO: reuse in tests +private external interface KeyboardEventInitExtended : KeyboardEventInit { + var keyCode: Int? +} + +@Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE") +private fun KeyboardEventInit.withKeyCode(keyCode: Int) = (this as KeyboardEventInitExtended).apply { + this.keyCode = keyCode +} + + +private fun InputEventExtended.toKeyboardEvent(): KeyboardEvent? { + if (inputType == "insertText") { + val key = data ?: return null + return KeyboardEvent( + "keydown", + KeyboardEventInit(key = key) + ) + } else if (inputType == "deleteContentBackward") { + return KeyboardEvent( + "keydown", + KeyboardEventInit(key = "Backspace", code="Backspace").withKeyCode(8) + ) + } + return null +} diff --git a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/WebImeInputService.kt b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/WebImeInputService.kt index 72eca7b75ca62..7753e5837f42d 100644 --- a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/WebImeInputService.kt +++ b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/WebImeInputService.kt @@ -37,7 +37,9 @@ internal class WebImeInputService(parentInputService: InputAwareInputService) : onEditCommand: (List) -> Unit, onImeActionPerformed: (ImeAction) -> Unit ) { - backingTextArea = BackingTextArea(imeOptions, onEditCommand, onImeActionPerformed) + backingTextArea = BackingTextArea(imeOptions, onEditCommand, onImeActionPerformed) { evt -> + sendKeyEvent(evt) + } backingTextArea?.register() showSoftwareKeyboard() diff --git a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/WebTextInputService.kt b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/WebTextInputService.kt index 26da486cc3aca..9b18e1ffb3357 100644 --- a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/WebTextInputService.kt +++ b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/WebTextInputService.kt @@ -18,7 +18,7 @@ package androidx.compose.ui.platform import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Rect -import androidx.compose.ui.input.InputMode +import androidx.compose.ui.input.key.KeyEvent import androidx.compose.ui.text.input.EditCommand import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.ImeOptions @@ -27,6 +27,7 @@ import androidx.compose.ui.text.input.TextFieldValue internal interface InputAwareInputService { fun getOffset(rect: Rect): Offset + fun sendKeyEvent(event: KeyEvent) fun isVirtualKeyboard(): Boolean } diff --git a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/window/ComposeWindow.web.kt b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/window/ComposeWindow.web.kt index 8af268eba9208..59b600516048f 100644 --- a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/window/ComposeWindow.web.kt +++ b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/window/ComposeWindow.web.kt @@ -26,6 +26,7 @@ import androidx.compose.ui.events.EventTargetListener import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Rect import androidx.compose.ui.input.InputModeManager +import androidx.compose.ui.input.key.KeyEvent import androidx.compose.ui.input.key.toComposeEvent import androidx.compose.ui.input.pointer.BrowserCursor import androidx.compose.ui.input.pointer.PointerEventType @@ -184,6 +185,10 @@ internal class ComposeWindow( val offsetY = viewportRect.top.toFloat().coerceAtLeast(0f) + (rect.top / density.density) return Offset(offsetX, offsetY) } + + override fun sendKeyEvent(event: KeyEvent) { + layer.onKeyboardEvent(event) + } } override val viewConfiguration = From bbb872c51ea89ae6f39033995c325cb56031fd07 Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Wed, 24 Apr 2024 14:52:47 +0200 Subject: [PATCH 2/6] Support composition input events --- .../compose/ui/platform/BackingTextArea.kt | 76 +++++++------------ 1 file changed, 27 insertions(+), 49 deletions(-) diff --git a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/BackingTextArea.kt b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/BackingTextArea.kt index 34024bbe80688..94cc29fcca445 100644 --- a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/BackingTextArea.kt +++ b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/BackingTextArea.kt @@ -25,6 +25,7 @@ import androidx.compose.ui.text.input.EditCommand import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.ImeOptions import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.text.input.SetComposingTextCommand import androidx.compose.ui.text.input.TextFieldValue import kotlinx.browser.document import org.w3c.dom.HTMLTextAreaElement @@ -102,18 +103,33 @@ internal class BackingTextArea( htmlInput.addEventListener("input", { evt -> evt.preventDefault() evt as InputEventExtended - val data = evt.data - if (evt.inputType == "insertLineBreak") { - if (imeOptions.singleLine) { - onImeActionPerformed(imeOptions.imeAction) + when (evt.inputType) { + "insertLineBreak" -> { + if (imeOptions.singleLine) { + onImeActionPerformed(imeOptions.imeAction) + } } - } else if ((data != null) && (data.length > 1)) { - sendImeValueToCompose(data) - } else { - val keyboardEvent = evt.toKeyboardEvent()?.toComposeEvent() - if (keyboardEvent != null) { - sendKey(keyboardEvent) + "insertCompositionText" -> { + onEditCommand(listOf(SetComposingTextCommand(evt.data!!, 1))) + } + "insertText" -> { + println(evt) + val data = evt.data!! ?: return@addEventListener + if ((data.length == 1)) { + sendKey(KeyboardEvent( + "keydown", + KeyboardEventInit(key = data) + ).toComposeEvent()) + } else if (data.length > 1) { + onEditCommand(listOf(CommitTextCommand(data, 1))) + } + } + "deleteContentBackward" -> { + sendKey(KeyboardEvent( + "keydown", + KeyboardEventInit(key = "Backspace", code="Backspace").withKeyCode(8) + ).toComposeEvent()) } } }) @@ -150,27 +166,6 @@ internal class BackingTextArea( textArea.setSelectionRange(textFieldValue.selection.start, textFieldValue.selection.end) } - private fun sendImeValueToCompose( - text: String, - newCursorPosition: Int? = null - ) { - if (newCursorPosition != null) { - onEditCommand( - listOf( - DeleteAllCommand(), - CommitTextCommand(text, newCursorPosition), - ) - ) - } else { - onEditCommand( - listOf( - CommitTextCommand(text, 1) - ) - ) - } - } - - fun dispose() { textArea.remove() } @@ -189,21 +184,4 @@ private external interface KeyboardEventInitExtended : KeyboardEventInit { @Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE") private fun KeyboardEventInit.withKeyCode(keyCode: Int) = (this as KeyboardEventInitExtended).apply { this.keyCode = keyCode -} - - -private fun InputEventExtended.toKeyboardEvent(): KeyboardEvent? { - if (inputType == "insertText") { - val key = data ?: return null - return KeyboardEvent( - "keydown", - KeyboardEventInit(key = key) - ) - } else if (inputType == "deleteContentBackward") { - return KeyboardEvent( - "keydown", - KeyboardEventInit(key = "Backspace", code="Backspace").withKeyCode(8) - ) - } - return null -} +} \ No newline at end of file From 30155ead8a5fe962d925a824343c38026273b815 Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Wed, 24 Apr 2024 17:02:46 +0200 Subject: [PATCH 3/6] Simplify KeyboardModeState signature --- .../compose/ui/window/ComposeWindow.web.kt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/window/ComposeWindow.web.kt b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/window/ComposeWindow.web.kt index 59b600516048f..7406bf33802f0 100644 --- a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/window/ComposeWindow.web.kt +++ b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/window/ComposeWindow.web.kt @@ -109,10 +109,8 @@ internal interface ComposeWindowState { } private sealed interface KeyboardModeState { - companion object { - object Virtual: KeyboardModeState - object Hardware: KeyboardModeState - } + object Virtual: KeyboardModeState + object Hardware: KeyboardModeState } internal class DefaultWindowState(private val viewportContainer: Element) : ComposeWindowState { @@ -169,7 +167,7 @@ internal class ComposeWindow( private val canvasEvents = EventTargetListener(canvas) - private var keyboardModeState: KeyboardModeState = KeyboardModeState.Companion.Hardware + private var keyboardModeState: KeyboardModeState = KeyboardModeState.Hardware private val platformContext: PlatformContext = object : PlatformContext { override val windowInfo get() = _windowInfo @@ -177,7 +175,7 @@ internal class ComposeWindow( override val inputModeManager: InputModeManager = DefaultInputModeManager() override val textInputService = object : WebTextInputService() { - override fun isVirtualKeyboard() = keyboardModeState == KeyboardModeState.Companion.Virtual + override fun isVirtualKeyboard() = keyboardModeState == KeyboardModeState.Virtual override fun getOffset(rect: Rect): Offset { val viewportRect = canvas.getBoundingClientRect() @@ -359,7 +357,7 @@ internal class ComposeWindow( event: TouchEvent, offset: Offset, ) { - keyboardModeState = KeyboardModeState.Companion.Virtual + keyboardModeState = KeyboardModeState.Virtual val eventType = when (event.type) { "touchstart" -> PointerEventType.Press "touchmove" -> PointerEventType.Move @@ -391,7 +389,7 @@ internal class ComposeWindow( private fun ComposeLayer.onMouseEvent( event: MouseEvent, ) { - keyboardModeState = KeyboardModeState.Companion.Hardware + keyboardModeState = KeyboardModeState.Hardware val eventType = when (event.type) { "mousedown" -> PointerEventType.Press "mousemove" -> PointerEventType.Move @@ -418,7 +416,7 @@ internal class ComposeWindow( private fun ComposeLayer.onWheelEvent( event: WheelEvent, ) { - keyboardModeState = KeyboardModeState.Companion.Hardware + keyboardModeState = KeyboardModeState.Hardware onMouseEvent( eventType = PointerEventType.Scroll, position = event.offset, From eb9c2e89d4e8c77af91695792ed99b82fc7d56f2 Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Fri, 26 Apr 2024 13:04:17 +0200 Subject: [PATCH 4/6] Remove redundant force cast --- .../kotlin/androidx/compose/ui/platform/BackingTextArea.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/BackingTextArea.kt b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/BackingTextArea.kt index 94cc29fcca445..c2245bdfcf1b8 100644 --- a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/BackingTextArea.kt +++ b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/BackingTextArea.kt @@ -114,8 +114,7 @@ internal class BackingTextArea( onEditCommand(listOf(SetComposingTextCommand(evt.data!!, 1))) } "insertText" -> { - println(evt) - val data = evt.data!! ?: return@addEventListener + val data = evt.data ?: return@addEventListener if ((data.length == 1)) { sendKey(KeyboardEvent( "keydown", From 275ccb75aeb68f4c51671e99e80109bd58cce89b Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Fri, 26 Apr 2024 14:58:09 +0200 Subject: [PATCH 5/6] De-hardcode keyCode value passed to the KeyEvent --- .../compose/ui/platform/BackingTextArea.kt | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/BackingTextArea.kt b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/BackingTextArea.kt index c2245bdfcf1b8..4dbcedd231256 100644 --- a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/BackingTextArea.kt +++ b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/BackingTextArea.kt @@ -17,10 +17,10 @@ package androidx.compose.ui.platform import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.input.key.Key import androidx.compose.ui.input.key.KeyEvent import androidx.compose.ui.input.key.toComposeEvent import androidx.compose.ui.text.input.CommitTextCommand -import androidx.compose.ui.text.input.DeleteAllCommand import androidx.compose.ui.text.input.EditCommand import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.ImeOptions @@ -33,10 +33,10 @@ import org.w3c.dom.events.KeyboardEvent import org.w3c.dom.events.KeyboardEventInit /** -* The purpose of this entity is to isolate synchronization between a TextFieldValue -* and the DOM HTMLTextAreaElement we are actually listening events on in order to show -* the virtual keyboard. -*/ + * The purpose of this entity is to isolate synchronization between a TextFieldValue + * and the DOM HTMLTextAreaElement we are actually listening events on in order to show + * the virtual keyboard. + */ internal class BackingTextArea( private val imeOptions: ImeOptions, private val onEditCommand: (List) -> Unit, @@ -110,25 +110,32 @@ internal class BackingTextArea( onImeActionPerformed(imeOptions.imeAction) } } + "insertCompositionText" -> { - onEditCommand(listOf(SetComposingTextCommand(evt.data!!, 1))) + val data = evt.data ?: return@addEventListener + onEditCommand(listOf(SetComposingTextCommand(data, 1))) } + "insertText" -> { val data = evt.data ?: return@addEventListener - if ((data.length == 1)) { - sendKey(KeyboardEvent( - "keydown", - KeyboardEventInit(key = data) - ).toComposeEvent()) + if (data.length == 1) { + sendKey( + KeyboardEvent( + "keydown", KeyboardEventInit(key = data) + ).toComposeEvent() + ) } else if (data.length > 1) { onEditCommand(listOf(CommitTextCommand(data, 1))) } } + "deleteContentBackward" -> { - sendKey(KeyboardEvent( - "keydown", - KeyboardEventInit(key = "Backspace", code="Backspace").withKeyCode(8) - ).toComposeEvent()) + sendKey( + KeyboardEvent( + "keydown", + KeyboardEventInit(key = "Backspace", code = "Backspace").withKeyCode(Key.Backspace) + ).toComposeEvent() + ) } } }) @@ -181,6 +188,7 @@ private external interface KeyboardEventInitExtended : KeyboardEventInit { } @Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE") -private fun KeyboardEventInit.withKeyCode(keyCode: Int) = (this as KeyboardEventInitExtended).apply { - this.keyCode = keyCode -} \ No newline at end of file +private fun KeyboardEventInit.withKeyCode(key: Key) = + (this as KeyboardEventInitExtended).apply { + this.keyCode = key.keyCode.toInt() + } \ No newline at end of file From 1eaa83125b15a414d291acf32c1d6547caba755b Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Fri, 26 Apr 2024 16:41:34 +0200 Subject: [PATCH 6/6] Pass sendKey as a param --- .../androidx/compose/ui/platform/WebImeInputService.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/WebImeInputService.kt b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/WebImeInputService.kt index 7753e5837f42d..199b1bea8259d 100644 --- a/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/WebImeInputService.kt +++ b/compose/ui/ui/src/webCommonW3C/kotlin/androidx/compose/ui/platform/WebImeInputService.kt @@ -37,9 +37,10 @@ internal class WebImeInputService(parentInputService: InputAwareInputService) : onEditCommand: (List) -> Unit, onImeActionPerformed: (ImeAction) -> Unit ) { - backingTextArea = BackingTextArea(imeOptions, onEditCommand, onImeActionPerformed) { evt -> - sendKeyEvent(evt) - } + backingTextArea = + BackingTextArea(imeOptions, onEditCommand, onImeActionPerformed, sendKey = { evt -> + sendKeyEvent(evt) + }) backingTextArea?.register() showSoftwareKeyboard()