Skip to content

Add swiftDialog lock parity: --button1disabled, --quitkey, --hidedefaultkeyboardaction#1

Merged
rodchristiansen merged 2 commits into
mainfrom
feature/swiftdialog-lock-parity
Jun 11, 2026
Merged

Add swiftDialog lock parity: --button1disabled, --quitkey, --hidedefaultkeyboardaction#1
rodchristiansen merged 2 commits into
mainfrom
feature/swiftdialog-lock-parity

Conversation

@rodchristiansen

Copy link
Copy Markdown
Contributor

Why

We drive csharpDialog as the Windows provisioning progress window (BootstrapMate userland → ProvisioningWatcher.ps1), the counterpart of swiftDialog in our macOS workflow. The Mac dialog runs locked — non-blocking but undismissable: --button1disabled, --hidedefaultkeyboardaction, and --quitkey remapped off the reflexive quit chord. csharpDialog had none of these, so the Windows window could be closed with X / Alt+F4 / Esc mid-provisioning.

What

  • --button1disabled — renders button1 disabled and engages a close lock: title-bar X and Alt+F4 are refused until a legitimate dismissal path runs (quit command, quit key, timeout, or a runtime button1: enable followed by a click). Implemented via a Closing gate + an AllowClose flag set by every legitimate path.
  • --quitkey <char> — Ctrl+<char> closes the dialog (Windows analog of swiftDialog's Cmd-based quit key; letters and digits).
  • --hidedefaultkeyboardaction — suppresses Esc, Enter, and Alt+F4 via PreviewKeyDown.
  • Command file: button1: enable|disable now toggles the footer button and the close lock together, and button1text: is actually applied (both were in ValidCommands/recognized but unimplemented).
  • --button1text / --button2text accepted as CLI aliases — the README documented them but the parser only accepted --button1/--button2.
  • README: new Lock / Dismissal Control section + button1: command-file docs.

Typical locked provisioning window

dialog --window --centeronscreen --topmost --button1text "Please wait" `
  --button1disabled --hidedefaultkeyboardaction --quitkey 0 `
  --commandfile "C:\ProgramData\ManagedInstalls\Temp\install-progress.txt"

then from the controlling script on completion:

button1text: Get Started
button1: enable

Validation

  • dotnet build -p:EnableWindowsTargeting=true on Core, CLI, and WPF: clean, zero warnings.
  • Not yet exercised on Windows hardware — the close-lock (X/Alt+F4), quitkey chord, and button toggling need a manual smoke test there.
  • Kiosk mode's existing Closing prevention is untouched; the new lock is an independent handler.

Out of scope

button2 has no UI in ProgressDialogWindow (single footer button), so button2text/button2: enable remain parsed-but-inert — left for a follow-up if a second button is added.

…boardaction

Adds the dismissal-control surface needed to run csharpDialog as a locked
provisioning progress window, matching how swiftDialog is driven on macOS:

- --button1disabled renders button1 disabled and engages a close lock: the
  title-bar X and Alt+F4 refuse to close the window until a legitimate
  dismissal path runs (quit command, quit key, timeout, or a runtime
  'button1: enable' followed by a click).
- --quitkey <char> makes Ctrl+<char> close the dialog (Windows analog of
  swiftDialog's Cmd-based quit key).
- --hidedefaultkeyboardaction suppresses Esc, Enter, and Alt+F4.
- Command file gains 'button1: enable|disable' (toggles the button and the
  close lock together) and 'button1text:' is now actually applied to the
  footer button; both were parsed but unimplemented.
- --button1text/--button2text accepted as CLI aliases of --button1/--button2;
  the README documented them but the parser did not accept them.
- Timeout and quit paths set AllowClose so they keep working under the lock.

Compile-validated with dotnet build -p:EnableWindowsTargeting=true (CLI and
WPF projects, zero warnings).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds “locked / non-dismissable” dialog behavior to the WPF progress window to match swiftDialog’s provisioning UX, plus related command-file and CLI parser enhancements.

Changes:

  • Add close-locking and keyboard-dismiss suppression (--button1disabled, --hidedefaultkeyboardaction, --quitkey) to the WPF dialog.
  • Implement previously-recognized-but-inert command-file commands (button1text:, button1: enable|disable) and add CLI aliases for button text options.
  • Document the new lock/dismissal controls and the new command-file behaviors in the README.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/CsharpDialog.WPF/Services/WpfDialogService.cs Implements close locking, quit-key handling, keyboard suppression, and button1 command support in the WPF service.
src/CsharpDialog.WPF/ProgressDialogWindow.xaml.cs Adds AllowClose gate and sets it on button click for lock-compatible closing.
src/CsharpDialog.Core/Services/CommandParser.cs Extends valid command set (button1/button2) for command-file parsing.
src/CsharpDialog.Core/DialogConfiguration.cs Adds configuration knobs for lock/dismissal control options.
src/CsharpDialog.Core/CommandLineParser.cs Adds CLI aliases and new lock/dismissal flags.
README.md Documents new lock/dismissal controls and button1 command-file usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/CsharpDialog.WPF/Services/WpfDialogService.cs Outdated
Comment on lines +24 to +28
// True while button1 is disabled: the window refuses to close via the
// title-bar X or Alt+F4 until a legitimate dismissal path sets
// _window.AllowClose (quit command, quit key, timeout, button1: enable
// followed by a click). swiftDialog --button1disabled parity.
private bool _closeLocked = false;
Comment on lines +148 to +154
if (okButton != null)
{
var button1 = configuration.Buttons.FirstOrDefault(b => b.Action is "button1" or "ok");
if (button1 != null && !string.IsNullOrEmpty(button1.Text))
okButton.Content = button1.Text;

if (configuration.Button1Disabled)
Comment on lines +14 to 18
"executeoutput", "width", "height", "position", "icon", "image", "button1text", "button2text",
"button1", "button2"
};

/// <summary>
Comment on lines +58 to +64
case "--quitkey":
if (!string.IsNullOrEmpty(value))
{
config.QuitKey = value;
i++;
}
break;
… normalization

- Attach the Closing gate unconditionally so a runtime 'button1: disable'
  command actually enforces the close lock, not just the startup flag.
- Accept bare valid-command lines (no colon) in the command file parser so
  the documented 'quit' form works; it was previously rejected, meaning the
  documented close path never fired.
- Record the configured button1 action in DialogResult.ButtonPressed on
  click instead of always reporting the default 'ok'.
- Normalize --quitkey to its first character at parse time.
- Fix the close-lock field comment to match the actual release behavior
  (released immediately on 'button1: enable').
@rodchristiansen

Copy link
Copy Markdown
Contributor Author

All five review comments addressed in bb76df4:

  1. Runtime close-lock bypass — the Closing gate is now attached unconditionally, so button1: disable arriving via the command file engages an enforced lock, not just the startup flag.
  2. Comment mismatch — field comment corrected: the lock releases immediately on button1: enable.
  3. ButtonPressed result — the footer button click now records the configured button1 action in DialogResult.ButtonPressed.
  4. Bare quitParseCommand accepts value-less valid commands; the documented colon-less quit form (used by existing scripts) previously never fired. This was a pre-existing bug surfaced by the review.
  5. --quitkey normalization — trimmed to its first character at parse time (whitespace-guarded).

Both projects rebuild clean with -p:EnableWindowsTargeting=true (0 warnings).

@rodchristiansen rodchristiansen merged commit 2c41025 into main Jun 11, 2026
1 check passed
@rodchristiansen rodchristiansen deleted the feature/swiftdialog-lock-parity branch June 11, 2026 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants