Skip to content

Commit 9be340c

Browse files
committed
Remove handling Esc key explicitly
1 parent dc65d7a commit 9be340c

File tree

3 files changed

+5
-21
lines changed

3 files changed

+5
-21
lines changed

compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/BasicContextMenuRepresentation.desktop.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ class DefaultContextMenuRepresentation(
115115
onKeyEvent = {
116116
if (it.type == KeyEventType.KeyDown) {
117117
when (it.key.nativeKeyCode) {
118-
java.awt.event.KeyEvent.VK_ESCAPE -> {
119-
state.status = ContextMenuState.Status.Closed
120-
true
121-
}
122118
java.awt.event.KeyEvent.VK_DOWN -> {
123119
inputModeManager!!.requestInputMode(InputMode.Keyboard)
124120
focusManager!!.moveFocus(FocusDirection.Next)

compose/material/material/src/desktopMain/kotlin/androidx/compose/material/DesktopAlertDialog.desktop.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,6 @@ object PopupAlertDialogProvider : AlertDialogProvider {
368368
},
369369
focusable = true,
370370
onDismissRequest = onDismissRequest,
371-
onKeyEvent = {
372-
if (it.type == KeyEventType.KeyDown && it.awtEventOrNull?.keyCode == KeyEvent.VK_ESCAPE) {
373-
onDismissRequest()
374-
true
375-
} else {
376-
false
377-
}
378-
},
379371
) {
380372
val scrimColor = Color.Black.copy(alpha = 0.32f) //todo configure scrim color in function arguments
381373
Box(

compose/material3/material3/src/skikoMain/kotlin/androidx/compose/material3/SkikoMenu.skiko.kt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ fun DropdownMenu(
124124
onDismissRequest = onDismissRequest,
125125
popupPositionProvider = popupPositionProvider,
126126
onKeyEvent = {
127-
handlePopupOnKeyEvent(it, onDismissRequest, focusManager!!, inputModeManager!!)
127+
handlePopupOnKeyEvent(it, focusManager!!, inputModeManager!!)
128128
},
129129
) {
130130
focusManager = LocalFocusManager.current
@@ -195,21 +195,17 @@ fun DropdownMenuItem(
195195
@ExperimentalComposeUiApi
196196
private fun handlePopupOnKeyEvent(
197197
keyEvent: KeyEvent,
198-
onDismissRequest: () -> Unit,
199198
focusManager: FocusManager,
200199
inputModeManager: InputModeManager
201200
): Boolean {
202-
return if (keyEvent.type == KeyEventType.KeyDown && keyEvent.key == Key.Escape) {
203-
onDismissRequest()
204-
true
205-
} else if (keyEvent.type == KeyEventType.KeyDown) {
206-
when {
207-
keyEvent.key == Key.DirectionDown -> {
201+
return if (keyEvent.type == KeyEventType.KeyDown) {
202+
when (keyEvent.key) {
203+
Key.DirectionDown -> {
208204
inputModeManager.requestInputMode(InputMode.Keyboard)
209205
focusManager.moveFocus(FocusDirection.Next)
210206
true
211207
}
212-
keyEvent.key == Key.DirectionUp -> {
208+
Key.DirectionUp -> {
213209
inputModeManager.requestInputMode(InputMode.Keyboard)
214210
focusManager.moveFocus(FocusDirection.Previous)
215211
true

0 commit comments

Comments
 (0)