Fix 3dot menu bug
This commit is contained in:
@@ -551,8 +551,11 @@ fun MainScreen(
|
||||
var showScriptDialog by remember { mutableStateOf(false) }
|
||||
var showPrinterSessionDialog by remember { mutableStateOf(false) }
|
||||
|
||||
var terminalInputViewRef by remember { mutableStateOf<TerminalInputView?>(null) }
|
||||
|
||||
LaunchedEffect(isFindDialogOpen) {
|
||||
if (isFindDialogOpen) {
|
||||
terminalInputViewRef?.hideSoftKeyboard()
|
||||
showFindDialog = true
|
||||
onSetFindDialogOpen(false)
|
||||
}
|
||||
@@ -560,13 +563,12 @@ fun MainScreen(
|
||||
|
||||
LaunchedEffect(isFtDialogOpen) {
|
||||
if (isFtDialogOpen) {
|
||||
terminalInputViewRef?.hideSoftKeyboard()
|
||||
showFtDialog = true
|
||||
onSetFtDialogOpen(false)
|
||||
}
|
||||
}
|
||||
|
||||
var terminalInputViewRef by remember { mutableStateOf<TerminalInputView?>(null) }
|
||||
|
||||
val lifecycleOwner = LocalLifecycleOwner.current
|
||||
DisposableEffect(lifecycleOwner) {
|
||||
val observer = LifecycleEventObserver { _, event ->
|
||||
@@ -721,14 +723,35 @@ fun MainScreen(
|
||||
fourColorOverride = fourColorOverride,
|
||||
hapticFeedbackEnabled = hapticFeedback,
|
||||
onClearShift = onClearShift,
|
||||
onConnectClick = { showConnectDialog = true },
|
||||
onConnectClick = {
|
||||
terminalInputViewRef?.hideSoftKeyboard()
|
||||
showConnectDialog = true
|
||||
},
|
||||
onDisconnectClick = { viewModel.disconnect() },
|
||||
onFtClick = { showFtDialog = true },
|
||||
onFieldInspectorClick = { showFieldInspectorDialog = true },
|
||||
onFindClick = { showFindDialog = true },
|
||||
onScreenExportClick = { showScreenExportDialog = true },
|
||||
onScriptClick = { showScriptDialog = true },
|
||||
onPrinterSessionClick = { showPrinterSessionDialog = true },
|
||||
onFtClick = {
|
||||
terminalInputViewRef?.hideSoftKeyboard()
|
||||
showFtDialog = true
|
||||
},
|
||||
onFieldInspectorClick = {
|
||||
terminalInputViewRef?.hideSoftKeyboard()
|
||||
showFieldInspectorDialog = true
|
||||
},
|
||||
onFindClick = {
|
||||
terminalInputViewRef?.hideSoftKeyboard()
|
||||
showFindDialog = true
|
||||
},
|
||||
onScreenExportClick = {
|
||||
terminalInputViewRef?.hideSoftKeyboard()
|
||||
showScreenExportDialog = true
|
||||
},
|
||||
onScriptClick = {
|
||||
terminalInputViewRef?.hideSoftKeyboard()
|
||||
showScriptDialog = true
|
||||
},
|
||||
onPrinterSessionClick = {
|
||||
terminalInputViewRef?.hideSoftKeyboard()
|
||||
showPrinterSessionDialog = true
|
||||
},
|
||||
onToggleLightPen = { viewModel.toggleLightPen() },
|
||||
onToggleDocMode = { viewModel.toggleDocMode() },
|
||||
onToggleWordWrap = { viewModel.toggleWordWrap() },
|
||||
@@ -739,7 +762,10 @@ fun MainScreen(
|
||||
viewModel.setFourColorOverride(next)
|
||||
AppSettings.setFourColorOverride(context, next)
|
||||
},
|
||||
onSettingsClick = { showSettingsDialog = true },
|
||||
onSettingsClick = {
|
||||
terminalInputViewRef?.hideSoftKeyboard()
|
||||
showSettingsDialog = true
|
||||
},
|
||||
onSendAid = { aid ->
|
||||
viewModel.sendAid(aid)
|
||||
terminalInputViewRef?.showSoftKeyboard()
|
||||
@@ -825,7 +851,10 @@ fun MainScreen(
|
||||
|
||||
if (showConnectDialog) {
|
||||
ConnectDialog(
|
||||
onDismiss = { showConnectDialog = false },
|
||||
onDismiss = {
|
||||
showConnectDialog = false
|
||||
terminalInputViewRef?.showSoftKeyboard()
|
||||
},
|
||||
onConnect = { host, port, model, dynamicRows, dynamicCols, luName, hostType, useTls, tlsVerifyCert, tn3270e, graphicsMode, cp, pType, pHost, pPort, pUser, pPass ->
|
||||
showConnectDialog = false
|
||||
viewModel.connect(host, port, model, dynamicRows, dynamicCols, luName, hostType, useTls, tlsVerifyCert, tn3270e, graphicsMode, cp, pType, pHost, pPort, pUser, pPass)
|
||||
@@ -839,7 +868,10 @@ fun MainScreen(
|
||||
initialHostType = viewModel.activeHostType,
|
||||
ftProgressState = ftState,
|
||||
client = viewModel.getClient(),
|
||||
onDismiss = { showFtDialog = false },
|
||||
onDismiss = {
|
||||
showFtDialog = false
|
||||
terminalInputViewRef?.showSoftKeyboard()
|
||||
},
|
||||
onStartTransfer = { config ->
|
||||
viewModel.startFileTransfer(config) { error ->
|
||||
if (error != null) {
|
||||
@@ -879,7 +911,10 @@ fun MainScreen(
|
||||
initialFourColorOverride = fourColorOverride,
|
||||
initialNumericFieldLock = AppSettings.getNumericFieldLock(context),
|
||||
initialAutoSkipEnabled = AppSettings.getAutoSkipEnabled(context),
|
||||
onDismiss = { showSettingsDialog = false },
|
||||
onDismiss = {
|
||||
showSettingsDialog = false
|
||||
terminalInputViewRef?.showSoftKeyboard()
|
||||
},
|
||||
onSave = { mask, blink, haptic, verify, gfx, defaultCp, theme, crosshair, style, blockSel, startup, dynRows, dynCols,
|
||||
doc, wrap, startCol, endCol, bell, bellCol, tabs, resetIns, fourCol, numLk, autoSk ->
|
||||
showSettingsDialog = false
|
||||
@@ -912,7 +947,10 @@ fun MainScreen(
|
||||
FieldInspectorDialog(
|
||||
client = viewModel.getClient(),
|
||||
screenVersion = screenVersion,
|
||||
onDismiss = { showFieldInspectorDialog = false },
|
||||
onDismiss = {
|
||||
showFieldInspectorDialog = false
|
||||
terminalInputViewRef?.showSoftKeyboard()
|
||||
},
|
||||
onJumpToField = { addr ->
|
||||
viewModel.setCursor(addr)
|
||||
terminalInputViewRef?.showSoftKeyboard()
|
||||
@@ -923,7 +961,10 @@ fun MainScreen(
|
||||
if (showFindDialog) {
|
||||
FindDialog(
|
||||
cols = cols,
|
||||
onDismiss = { showFindDialog = false },
|
||||
onDismiss = {
|
||||
showFindDialog = false
|
||||
terminalInputViewRef?.showSoftKeyboard()
|
||||
},
|
||||
onFind = { query: String, matchCase: Boolean, forward: Boolean ->
|
||||
viewModel.find(query, matchCase, forward)
|
||||
},
|
||||
@@ -941,13 +982,19 @@ fun MainScreen(
|
||||
programSymbolManager = viewModel.getClient()?.programSymbolManager,
|
||||
graphicsPlane = viewModel.getClient()?.graphicsPlane,
|
||||
maskHidden = maskHiddenInput,
|
||||
onDismiss = { showScreenExportDialog = false }
|
||||
onDismiss = {
|
||||
showScreenExportDialog = false
|
||||
terminalInputViewRef?.showSoftKeyboard()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
if (showScriptDialog) {
|
||||
ScriptDialog(
|
||||
onDismiss = { showScriptDialog = false },
|
||||
onDismiss = {
|
||||
showScriptDialog = false
|
||||
terminalInputViewRef?.showSoftKeyboard()
|
||||
},
|
||||
onExecuteScript = { script: String, onStatus: (String) -> Unit, onComplete: (String?) -> Unit ->
|
||||
viewModel.executeScript(script, onStatus, onComplete)
|
||||
}
|
||||
@@ -960,7 +1007,10 @@ fun MainScreen(
|
||||
initialHost = activeHost,
|
||||
initialCodePage = codePage,
|
||||
initialUseTls = isTlsActive,
|
||||
onDismiss = { showPrinterSessionDialog = false }
|
||||
onDismiss = {
|
||||
showPrinterSessionDialog = false
|
||||
terminalInputViewRef?.showSoftKeyboard()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.ui.window.PopupProperties
|
||||
import haus.nightmare.lib3270j.ConnectionState
|
||||
import haus.nightmare.lib3270j.protocol.DS3270Constants.*
|
||||
|
||||
@@ -61,6 +63,11 @@ fun TwoRowKeyBar(
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
var menuExpanded by remember { mutableStateOf(false) }
|
||||
var lastDismissTime by remember { mutableLongStateOf(0L) }
|
||||
|
||||
BackHandler(enabled = menuExpanded) {
|
||||
menuExpanded = false
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = modifier
|
||||
@@ -83,11 +90,22 @@ fun TwoRowKeyBar(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
hapticFeedbackEnabled = hapticFeedbackEnabled,
|
||||
innerPaddingHorizontal = 0.dp,
|
||||
onClick = { menuExpanded = true }
|
||||
onClick = {
|
||||
if (System.currentTimeMillis() - lastDismissTime > 200L) {
|
||||
menuExpanded = !menuExpanded
|
||||
}
|
||||
}
|
||||
)
|
||||
DropdownMenu(
|
||||
expanded = menuExpanded,
|
||||
onDismissRequest = { menuExpanded = false },
|
||||
onDismissRequest = {
|
||||
menuExpanded = false
|
||||
lastDismissTime = System.currentTimeMillis()
|
||||
},
|
||||
properties = PopupProperties(
|
||||
focusable = false,
|
||||
dismissOnClickOutside = true
|
||||
),
|
||||
modifier = Modifier
|
||||
.background(Color(0xFF2C2D30))
|
||||
.heightIn(max = 420.dp)
|
||||
|
||||
@@ -111,4 +111,10 @@ class TerminalInputView(context: Context) : View(context) {
|
||||
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
|
||||
imm?.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT)
|
||||
}
|
||||
|
||||
fun hideSoftKeyboard() {
|
||||
clearFocus()
|
||||
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
|
||||
imm?.hideSoftInputFromWindow(windowToken, 0)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user