Skip to content

Commit

Permalink
Remove handling Esc key explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
MatkovIvan committed Jul 26, 2023
1 parent dc65d7a commit 9be340c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ class DefaultContextMenuRepresentation(
onKeyEvent = {
if (it.type == KeyEventType.KeyDown) {
when (it.key.nativeKeyCode) {
java.awt.event.KeyEvent.VK_ESCAPE -> {
state.status = ContextMenuState.Status.Closed
true
}
java.awt.event.KeyEvent.VK_DOWN -> {
inputModeManager!!.requestInputMode(InputMode.Keyboard)
focusManager!!.moveFocus(FocusDirection.Next)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,6 @@ object PopupAlertDialogProvider : AlertDialogProvider {
},
focusable = true,
onDismissRequest = onDismissRequest,
onKeyEvent = {
if (it.type == KeyEventType.KeyDown && it.awtEventOrNull?.keyCode == KeyEvent.VK_ESCAPE) {
onDismissRequest()
true
} else {
false
}
},
) {
val scrimColor = Color.Black.copy(alpha = 0.32f) //todo configure scrim color in function arguments
Box(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fun DropdownMenu(
onDismissRequest = onDismissRequest,
popupPositionProvider = popupPositionProvider,
onKeyEvent = {
handlePopupOnKeyEvent(it, onDismissRequest, focusManager!!, inputModeManager!!)
handlePopupOnKeyEvent(it, focusManager!!, inputModeManager!!)
},
) {
focusManager = LocalFocusManager.current
Expand Down Expand Up @@ -195,21 +195,17 @@ fun DropdownMenuItem(
@ExperimentalComposeUiApi
private fun handlePopupOnKeyEvent(
keyEvent: KeyEvent,
onDismissRequest: () -> Unit,
focusManager: FocusManager,
inputModeManager: InputModeManager
): Boolean {
return if (keyEvent.type == KeyEventType.KeyDown && keyEvent.key == Key.Escape) {
onDismissRequest()
true
} else if (keyEvent.type == KeyEventType.KeyDown) {
when {
keyEvent.key == Key.DirectionDown -> {
return if (keyEvent.type == KeyEventType.KeyDown) {
when (keyEvent.key) {
Key.DirectionDown -> {
inputModeManager.requestInputMode(InputMode.Keyboard)
focusManager.moveFocus(FocusDirection.Next)
true
}
keyEvent.key == Key.DirectionUp -> {
Key.DirectionUp -> {
inputModeManager.requestInputMode(InputMode.Keyboard)
focusManager.moveFocus(FocusDirection.Previous)
true
Expand Down

0 comments on commit 9be340c

Please sign in to comment.