mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-04 13:41:37 -05:00
fix(help): let F1 set a placed part instead of opening help
The Help menu's F1 shortcut took the key before the plate view, so F1 in Clone/Add Part opened help rather than setting the part in place as it always has. Actions can now claim F1; Clone does, and MainForm lets the key through to the plate view while it is active. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
35be95b843
commit
afdf196754
5 files changed
+30
No files matched your search
@@ -60,4 +60,21 @@ public class ActionCloneTests
|
||||
Assert.Empty(plate.Parts);
|
||||
Assert.True(Assert.Single(view.SelectedParts).IsSelected);
|
||||
}, TimeSpan.FromMinutes(1), "The STA test did not complete.");
|
||||
|
||||
[Fact]
|
||||
public void F1SetsThePartInPlaceInsteadOfOpeningHelp() => StaTestThread.Run(() =>
|
||||
{
|
||||
var plate = new Plate(48, 96);
|
||||
using var view = new PlateView { Plate = plate, Size = new System.Drawing.Size(600, 600) };
|
||||
view.ZoomToFit();
|
||||
view.SetAction(typeof(ActionClone), Square("new"));
|
||||
|
||||
Assert.True(view.ActionHandlesF1);
|
||||
Raise(view, "OnKeyDown", new KeyEventArgs(Keys.F1));
|
||||
|
||||
Assert.Single(plate.Parts);
|
||||
|
||||
view.SetAction(typeof(ActionSelect));
|
||||
Assert.False(view.ActionHandlesF1);
|
||||
}, TimeSpan.FromMinutes(1), "The STA test did not complete.");
|
||||
}
|
||||
@@ -39,6 +39,9 @@ namespace OpenNest.Actions
|
||||
/// <summary>The help topic F1 opens while this action is active, or null for the general help.</summary>
|
||||
public virtual string HelpTopic => null;
|
||||
|
||||
/// <summary>Whether the action uses F1 itself, so F1 reaches the plate view instead of opening help.</summary>
|
||||
public virtual bool HandlesF1 => false;
|
||||
|
||||
public virtual void OnPlateChanged() { }
|
||||
|
||||
public virtual void ConnectEvents() { }
|
||||
|
||||
@@ -110,6 +110,9 @@ namespace OpenNest.Actions
|
||||
|
||||
public override bool SurvivesPlateChange => true;
|
||||
|
||||
// F1 sets the part in place, as it always has; help stays on the Help menu.
|
||||
public override bool HandlesF1 => true;
|
||||
|
||||
public override void OnPlateChanged() => SelectPreviews();
|
||||
|
||||
public override void ConnectEvents()
|
||||
|
||||
@@ -883,6 +883,9 @@ namespace OpenNest.Controls
|
||||
/// <summary>The help topic for the current action, or null when it has none.</summary>
|
||||
public string ActionHelpTopic => actionManager.CurrentAction?.HelpTopic;
|
||||
|
||||
/// <summary>Whether the current action takes F1 for itself instead of help.</summary>
|
||||
public bool ActionHandlesF1 => actionManager.CurrentAction?.HandlesF1 == true;
|
||||
|
||||
public void AlignSelected(AlignType alignType) => selection.AlignSelected(alignType);
|
||||
|
||||
public void AlignSelected(AlignType alignType, LayoutPart fixedPart) =>
|
||||
|
||||
@@ -99,6 +99,10 @@ namespace OpenNest.Forms
|
||||
}
|
||||
if (ProcessUndoKeys(keyData))
|
||||
return true;
|
||||
// A tool that uses F1 itself (Clone sets the part) gets it before help: skip the
|
||||
// Help menu shortcut so the key reaches the plate view.
|
||||
if (keyData == Keys.F1 && activeForm?.PlateView?.ActionHandlesF1 == true)
|
||||
return false;
|
||||
// F1 opens the active tool's topic before the Help menu's general help.
|
||||
if (keyData == Keys.F1 && activeForm?.PlateView?.ActionHelpTopic is { } topic)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user