From a8061a6d15a0b56fad1688a5d36126230f08d562 Mon Sep 17 00:00:00 2001 From: Robin Davies Date: Tue, 8 Oct 2024 04:20:37 -0400 Subject: [PATCH] Enter key handling for dialogs. --- react/src/AboutDialog.tsx | 1 + react/src/AppThemed.tsx | 1 + react/src/BankDialog.tsx | 5 ++++- react/src/DialogEx.tsx | 6 ++++- react/src/FilePropertyDialog.tsx | 7 ++++-- .../src/FilePropertyDirectorySelectDialog.tsx | 1 + react/src/FullScreenIME.tsx | 22 ++++++++++++------- react/src/JackServerSettingsDialog.tsx | 13 ++++++++--- react/src/LoadPluginDialog.tsx | 20 +++++++++++++++-- react/src/MidiBindingsDialog.tsx | 2 ++ react/src/OkCancelDialog.tsx | 1 + react/src/OptionsDialog.tsx | 2 +- react/src/PluginInfoDialog.tsx | 4 +++- react/src/PluginPresetsDialog.tsx | 4 +++- react/src/PresetDialog.tsx | 4 +++- ...SelectDialog.tsx => RadioSelectDialog.tsx} | 19 ++++++---------- react/src/RenameDialog.tsx | 1 + react/src/SelectChannelsDialog.tsx | 8 +++++-- react/src/SelectMidiChannelsDialog.tsx | 4 +++- react/src/SelectThemeDialog.tsx | 4 +++- react/src/SettingsDialog.tsx | 7 +++--- react/src/SnapshotDialog.tsx | 1 + react/src/SnapshotPropertiesDialog.tsx | 1 + react/src/SystemMidiBindingsDialog.tsx | 1 + react/src/UpdateDialog.tsx | 2 ++ react/src/UploadFileDialog.tsx | 12 ++++++---- react/src/UploadPresetDialog.tsx | 3 ++- react/src/WifiConfigDialog.tsx | 17 +++++++++++--- react/src/WifiDirectConfigDialog.tsx | 2 +- react/src/ZoomedUiControl.tsx | 1 + todo.txt | 4 ++++ 31 files changed, 131 insertions(+), 49 deletions(-) rename react/src/{ListSelectDialog.tsx => RadioSelectDialog.tsx} (85%) diff --git a/react/src/AboutDialog.tsx b/react/src/AboutDialog.tsx index 8a65e02..eb95eef 100644 --- a/react/src/AboutDialog.tsx +++ b/react/src/AboutDialog.tsx @@ -199,6 +199,7 @@ const AboutDialog = withStyles(styles, { withTheme: true })( return ( { this.props.onClose() }} TransitionComponent={Transition} + onEnterKey={() => { this.props.onClose() }} style={{ userSelect: "none" }} > diff --git a/react/src/AppThemed.tsx b/react/src/AppThemed.tsx index 73615d5..4845347 100644 --- a/react/src/AppThemed.tsx +++ b/react/src/AppThemed.tsx @@ -1020,6 +1020,7 @@ const AppThemed = withStyles(appStyles)(class extends ResizeResponsiveComponent< diff --git a/react/src/BankDialog.tsx b/react/src/BankDialog.tsx index 2b0940f..e22fd4c 100644 --- a/react/src/BankDialog.tsx +++ b/react/src/BankDialog.tsx @@ -409,6 +409,7 @@ const BankDialog = withStyles(styles, { withTheme: true })( return ( { this.handleDialogClose() }} TransitionComponent={Transition} + onEnterKey={()=>{}} style={{ userSelect: "none" }} >
@@ -544,7 +545,9 @@ const BankDialog = withStyles(styles, { withTheme: true })( /> this.handleDeletePromptClose()} - style={{ userSelect: "none" }}> + style={{ userSelect: "none" }} + onEnterKey={()=>{ this.handleDeletePromptOk() }} + > Are you sure you want to delete bank '{this.getSelectedBankName()}'? diff --git a/react/src/DialogEx.tsx b/react/src/DialogEx.tsx index 4879613..0fb78d9 100644 --- a/react/src/DialogEx.tsx +++ b/react/src/DialogEx.tsx @@ -25,6 +25,7 @@ import Dialog, {DialogProps} from '@mui/material/Dialog'; interface DialogExProps extends DialogProps { tag: string; fullwidth?: boolean; + onEnterKey: () => void; } interface DialogExState { @@ -186,7 +187,10 @@ class DialogEx extends React.Component implements I } onEnterKey() { - + if (this.props.onEnterKey) + { + this.props.onEnterKey(); + } } onKeyDown(evt: React.KeyboardEvent) { diff --git a/react/src/FilePropertyDialog.tsx b/react/src/FilePropertyDialog.tsx index 7a15512..7fdeecc 100644 --- a/react/src/FilePropertyDialog.tsx +++ b/react/src/FilePropertyDialog.tsx @@ -484,9 +484,12 @@ export default withStyles(styles, { withTheme: true })( fullScreen={this.state.fullScreen} onClose={() => { this.props.onCancel(); - }} + }} + onEnterKey={()=> { + this.openSelectedFile(); + }} open={this.props.open} tag="fileProperty" - fullWidth maxWidth="xl" + fullWidth maxWidth="md" PaperProps={ this.state.fullScreen ? {} diff --git a/react/src/FilePropertyDirectorySelectDialog.tsx b/react/src/FilePropertyDirectorySelectDialog.tsx index ec468c3..a9b341f 100644 --- a/react/src/FilePropertyDirectorySelectDialog.tsx +++ b/react/src/FilePropertyDirectorySelectDialog.tsx @@ -319,6 +319,7 @@ export default class FilePropertyDirectorySelectDialog extends ResizeResponsiveC { this.onClose(); }} aria-labelledby="Rename-dialog-title" fullScreen={this.state.fullScreen} style={{ userSelect: "none" }} + onEnterKey={()=>{ this.onOK(); }} PaperProps={{ style: { minHeight: "80%", maxHeight: "80%", minWidth: "75%", maxWidth: "75%", overflowY: "visible" } }} > diff --git a/react/src/FullScreenIME.tsx b/react/src/FullScreenIME.tsx index dcc9a08..f3ec69a 100644 --- a/react/src/FullScreenIME.tsx +++ b/react/src/FullScreenIME.tsx @@ -166,15 +166,19 @@ const FullScreenIME = } } + onOk() { + if (this.inputChanged) { + this.inputChanged = false; + this.validateInput(true); + } + else { + this.props.onClose(); + } + } + onInputKeyPress(e: any): void { if (e.charCode === 13) { - if (this.inputChanged) { - this.inputChanged = false; - this.validateInput(true); - } - else { - this.props.onClose(); - } + this.onOk(); } } @@ -196,7 +200,9 @@ const FullScreenIME = let value = this.props.value; return ( - this.handleClose(e, r)} > + this.handleClose(e, r)} + onEnterKey={()=>{ /*nothing*/}} + >
+ { + this.handleApply(); + }} + + >
diff --git a/react/src/LoadPluginDialog.tsx b/react/src/LoadPluginDialog.tsx index 6cfaec5..2a9eeba 100644 --- a/react/src/LoadPluginDialog.tsx +++ b/react/src/LoadPluginDialog.tsx @@ -375,8 +375,22 @@ export const LoadPluginDialog = e.preventDefault(); this.cancel(); } - handleOk(e: SyntheticEvent): void { - e.preventDefault(); + handleOk(e?: SyntheticEvent): void { + if (e) { + e.preventDefault(); + } + + let selectedPlugin: UiPlugin | undefined = undefined; + if (this.state.selected_uri) { + let t = this.model.getUiPlugin(this.state.selected_uri); + if (t) selectedPlugin = t; + } + if (!selectedPlugin) + { + return; + } + + if (this.state.selected_uri) { this.props.onOk(this.state.selected_uri); } @@ -688,7 +702,9 @@ export const LoadPluginDialog = return ( { this.handleOk(); }} onKeyPress={(e) => { this.handleKeyPress(e); }} + fullScreen={true} TransitionComponent={undefined} maxWidth={false} diff --git a/react/src/MidiBindingsDialog.tsx b/react/src/MidiBindingsDialog.tsx index bd4c6f1..1fe9991 100644 --- a/react/src/MidiBindingsDialog.tsx +++ b/react/src/MidiBindingsDialog.tsx @@ -326,6 +326,8 @@ export const MidiBindingDialog = {}} + >
diff --git a/react/src/OkCancelDialog.tsx b/react/src/OkCancelDialog.tsx index 726ac3b..c46384e 100644 --- a/react/src/OkCancelDialog.tsx +++ b/react/src/OkCancelDialog.tsx @@ -63,6 +63,7 @@ export default class OkCancelDialog extends React.Component diff --git a/react/src/OptionsDialog.tsx b/react/src/OptionsDialog.tsx index bdae319..890df65 100644 --- a/react/src/OptionsDialog.tsx +++ b/react/src/OptionsDialog.tsx @@ -70,7 +70,7 @@ function OptionsDialog(props: OptionsDialogProps) { onClose(); }; return ( - + {}} > {title && ( diff --git a/react/src/PluginInfoDialog.tsx b/react/src/PluginInfoDialog.tsx index 2e9bfca..6d9e887 100644 --- a/react/src/PluginInfoDialog.tsx +++ b/react/src/PluginInfoDialog.tsx @@ -235,7 +235,9 @@ const PluginInfoDialog = withStyles(styles)((props: PluginInfoProps) => { {open && ( - +
diff --git a/react/src/PluginPresetsDialog.tsx b/react/src/PluginPresetsDialog.tsx index 35bd05a..9e012c9 100644 --- a/react/src/PluginPresetsDialog.tsx +++ b/react/src/PluginPresetsDialog.tsx @@ -361,7 +361,9 @@ const PluginPresetsDialog = withStyles(styles, { withTheme: true })( return ( { this.handleDialogClose() }} TransitionComponent={Transition} - style={{userSelect: "none"}}> + style={{userSelect: "none"}} + onEnterKey={()=>{}} + >
diff --git a/react/src/PresetDialog.tsx b/react/src/PresetDialog.tsx index 6f7d159..5d5f9c6 100644 --- a/react/src/PresetDialog.tsx +++ b/react/src/PresetDialog.tsx @@ -340,7 +340,9 @@ const PresetDialog = withStyles(styles, { withTheme: true })( return ( { this.handleDialogClose() }} TransitionComponent={Transition} - style={{userSelect: "none"}}> + style={{userSelect: "none"}} + onEnterKey={()=>{}} + >
diff --git a/react/src/ListSelectDialog.tsx b/react/src/RadioSelectDialog.tsx similarity index 85% rename from react/src/ListSelectDialog.tsx rename to react/src/RadioSelectDialog.tsx index 03f145d..6856fb0 100644 --- a/react/src/ListSelectDialog.tsx +++ b/react/src/RadioSelectDialog.tsx @@ -18,7 +18,6 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import React from 'react'; -import Button from '@mui/material/Button'; import Radio from '@mui/material/Radio'; @@ -29,11 +28,10 @@ import ListItemIcon from '@mui/material/ListItemIcon'; import ListItemText from '@mui/material/ListItemText'; import DialogEx from './DialogEx'; -import DialogActions from '@mui/material/DialogActions'; import ResizeResponsiveComponent from './ResizeResponsiveComponent'; -export interface ListSelectDialogProps { +export interface RadioSelectDialogProps { open: boolean, title: string, width: number, @@ -43,15 +41,15 @@ export interface ListSelectDialogProps { onClose: () => void }; -export interface ListSelectDialogState { +export interface RadioSelectDialogState { fullScreen: boolean; }; -export default class ListSelectDialog extends ResizeResponsiveComponent { +export default class RadioSelectDialog extends ResizeResponsiveComponent { refText: React.RefObject; - constructor(props: ListSelectDialogProps) { + constructor(props: RadioSelectDialogProps) { super(props); this.state = { fullScreen: false @@ -82,7 +80,9 @@ export default class ListSelectDialog extends ResizeResponsiveComponentthis.props.onClose()} open={this.props.open}> + this.props.onClose()} open={this.props.open} + onEnterKey={()=>{ }} + > { this.props.items.map( @@ -105,11 +105,6 @@ export default class ListSelectDialog extends ResizeResponsiveComponent - - - ); } diff --git a/react/src/RenameDialog.tsx b/react/src/RenameDialog.tsx index 583dadb..cafe277 100644 --- a/react/src/RenameDialog.tsx +++ b/react/src/RenameDialog.tsx @@ -117,6 +117,7 @@ export default class RenameDialog extends ResizeResponsiveComponent{}} > + Select Channels {availableChannels.map((channel) => ( @@ -154,7 +156,9 @@ function SelectChannelsDialog(props: SelectChannelsDialogProps) { } return ( - + {}} + > handleListItemClick("Stereo")} key={"Stereo"} selected={selectionKey === "Stereo"} > diff --git a/react/src/SelectMidiChannelsDialog.tsx b/react/src/SelectMidiChannelsDialog.tsx index df621bc..23b74a5 100644 --- a/react/src/SelectMidiChannelsDialog.tsx +++ b/react/src/SelectMidiChannelsDialog.tsx @@ -93,7 +93,9 @@ function SelectMidiChannelsDialog(props: SelectMidiChannelsDialogProps) { return ( - + Select MIDI Device {availableChannels.map((channel) => ( diff --git a/react/src/SelectThemeDialog.tsx b/react/src/SelectThemeDialog.tsx index c4db808..f829045 100644 --- a/react/src/SelectThemeDialog.tsx +++ b/react/src/SelectThemeDialog.tsx @@ -64,7 +64,9 @@ function SelectThemesDialog(props: SelectThemesDialogProps) { return ( - + Theme diff --git a/react/src/SettingsDialog.tsx b/react/src/SettingsDialog.tsx index f70b42a..5e0389e 100644 --- a/react/src/SettingsDialog.tsx +++ b/react/src/SettingsDialog.tsx @@ -20,7 +20,7 @@ import React, { SyntheticEvent, Component } from 'react'; import Switch from "@mui/material/Switch"; import OkCancelDialog from './OkCancelDialog'; -import ListSelectDialog from './ListSelectDialog'; +import RadioSelectDialog from './RadioSelectDialog'; import IconButton from '@mui/material/IconButton'; import Typography from '@mui/material/Typography'; import { PiPedalModel, PiPedalModelFactory, State } from './PiPedalModel'; @@ -542,6 +542,7 @@ const SettingsDialog = withStyles(styles, { withTheme: true })( { this.props.onClose() }} TransitionComponent={Transition} style={{ userSelect: "none" }} + onEnterKey={()=>{}} >
@@ -882,7 +883,7 @@ const SettingsDialog = withStyles(styles, { withTheme: true })( { (this.state.showGovernorSettingsDialog) && ( - - + ) } { diff --git a/react/src/SnapshotDialog.tsx b/react/src/SnapshotDialog.tsx index 4b0cc13..3076795 100644 --- a/react/src/SnapshotDialog.tsx +++ b/react/src/SnapshotDialog.tsx @@ -108,6 +108,7 @@ export default class SnapshotDialog extends ResizeResponsiveComponent{} } >
diff --git a/react/src/SnapshotPropertiesDialog.tsx b/react/src/SnapshotPropertiesDialog.tsx index 8f3d33a..f828742 100644 --- a/react/src/SnapshotPropertiesDialog.tsx +++ b/react/src/SnapshotPropertiesDialog.tsx @@ -113,6 +113,7 @@ export default class SnapshotPropertiesDialog extends ResizeResponsiveComponent< return ( { this.handleOk(); }} >
diff --git a/react/src/SystemMidiBindingsDialog.tsx b/react/src/SystemMidiBindingsDialog.tsx index 4c398d4..52ad0e0 100644 --- a/react/src/SystemMidiBindingsDialog.tsx +++ b/react/src/SystemMidiBindingsDialog.tsx @@ -328,6 +328,7 @@ export const SystemMidiBindingDialog = {}} >
diff --git a/react/src/UpdateDialog.tsx b/react/src/UpdateDialog.tsx index 3ece574..2347948 100644 --- a/react/src/UpdateDialog.tsx +++ b/react/src/UpdateDialog.tsx @@ -166,6 +166,7 @@ export default class UpdateDialog extends ResizeResponsiveComponent { this.handleClose(); }} style={{ userSelect: "none" }} + onEnterKey={()=>{ this.handleOK();}} >
@@ -288,6 +289,7 @@ export default class UpdateDialog extends ResizeResponsiveComponent { this.handleCloseAlert(); }} aria-describedby="Alert Dialog" + onEnterKey={()=>{ this.handleCloseAlert(); }} > diff --git a/react/src/UploadFileDialog.tsx b/react/src/UploadFileDialog.tsx index 368432d..689ff5d 100644 --- a/react/src/UploadFileDialog.tsx +++ b/react/src/UploadFileDialog.tsx @@ -311,9 +311,13 @@ export default class UploadFileDialog extends ResizeResponsiveComponent this.handleClose()} - fullScreen={this.state.fullScreen} - style={{ userSelect: "none" }} + this.handleClose()} + fullScreen={false} + fullWidth={true} + maxWidth={"sm"} + style={{ userSelect: "none",}} + onEnterKey={()=>{ this.handleClose(); }} + >
@@ -326,7 +330,7 @@ export default class UploadFileDialog extends ResizeResponsiveComponent
this.handleClose()} + this.handleClose()} fullScreen={this.state.fullScreen} style={{userSelect: "none"}} + onEnterKey={()=>{}} > {this.props.title} diff --git a/react/src/WifiConfigDialog.tsx b/react/src/WifiConfigDialog.tsx index 0fcbc05..886af57 100644 --- a/react/src/WifiConfigDialog.tsx +++ b/react/src/WifiConfigDialog.tsx @@ -328,6 +328,13 @@ const WifiConfigDialog = withStyles(styles, { withTheme: true })( } return result; } + handleWarningDialogOk() + { + this.setState({ showWifiWarningDialog: false }); + this.handleOk(true); + } + + render() { let props = this.props; let classes = this.props.classes; @@ -569,7 +576,11 @@ const WifiConfigDialog = withStyles(styles, { withTheme: true })( {this.state.showHelpDialog && ( + style={{ userSelect: "none" }} + onEnterKey={()=>{ + this.setState({ showHelpDialog: false }); + }} + > PiPedal Auto-Hotspot @@ -633,6 +644,7 @@ const WifiConfigDialog = withStyles(styles, { withTheme: true })( )} {this.state.showWifiWarningDialog && ( { this.handleWarningDialogOk();}} style={{ userSelect: "none" }}> @@ -654,8 +666,7 @@ const WifiConfigDialog = withStyles(styles, { withTheme: true })( Cancel diff --git a/react/src/WifiDirectConfigDialog.tsx b/react/src/WifiDirectConfigDialog.tsx index 268f88e..679a2ab 100644 --- a/react/src/WifiDirectConfigDialog.tsx +++ b/react/src/WifiDirectConfigDialog.tsx @@ -307,7 +307,7 @@ const WifiDirectConfigDialog = withStyles(styles, { withTheme: true })( return ( {}} > {this.state.landscapeLayout && ( diff --git a/react/src/ZoomedUiControl.tsx b/react/src/ZoomedUiControl.tsx index 57522f9..06d71b7 100644 --- a/react/src/ZoomedUiControl.tsx +++ b/react/src/ZoomedUiControl.tsx @@ -222,6 +222,7 @@ const ZoomedUiControl = withStyles(styles, { withTheme: true })( { this.props.onDialogClose() }} onAbort={() => { this.props.onDialogClose() }} + onEnterKey={()=>{/*nothing*/}} >