Skip to content

Commit

Permalink
F11 / ESC key to toggle fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
zoff99 committed Nov 1, 2023
1 parent d331037 commit 07198ef
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ import androidx.compose.ui.draw.scale
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.key
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
Expand All @@ -61,6 +63,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.WindowPlacement
import androidx.compose.ui.window.WindowPosition
import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberWindowState
Expand Down Expand Up @@ -960,7 +963,22 @@ private fun MainAppStart()

if (isOpen)
{
Window(onCloseRequest = { isAskingToClose = true }, title = "TRIfA", icon = appIcon, state = state) {
Window(onCloseRequest = { isAskingToClose = true }, title = "TRIfA",
icon = appIcon, state = state,
onKeyEvent = {
when (it.key) {
Key.F11 -> {
state.placement = WindowPlacement.Fullscreen
true
}
Key.Escape -> {
state.placement = WindowPlacement.Floating
true
}
else -> false
}
}
) {
if (isAskingToClose)
{
Dialog(
Expand Down Expand Up @@ -1048,7 +1066,6 @@ fun lock_data_dir_input()
savepathstore.updateEnabled(false)
}


fun actionButton(
text: String,
action: () -> Unit
Expand All @@ -1059,4 +1076,4 @@ fun actionButton(
button.addActionListener { action() }

return button
}
}

0 comments on commit 07198ef

Please sign in to comment.