diff --git a/CHANGELOG.md b/CHANGELOG.md
index e71aa75109..29f882de9d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
- [GUI] Label ordering buttons (#3416 by: HebaruSan; reviewed: DasSkelett)
- [GUI] Suppress incompatibility warning at game launch (#3453 by: HebaruSan; reviewed: DasSkelett)
- [CLI] Options for ckan show to hide sections (#3461 by: HebaruSan; reviewed: DasSkelett)
+- [Multiple] Show context menu on menu key press (#3446 by: HebaruSan; reviewed: DasSkelett)
### Bugfixes
diff --git a/ConsoleUI/Toolkit/ConsolePopupMenu.cs b/ConsoleUI/Toolkit/ConsolePopupMenu.cs
index 6992071280..c1558d9fe5 100644
--- a/ConsoleUI/Toolkit/ConsolePopupMenu.cs
+++ b/ConsoleUI/Toolkit/ConsolePopupMenu.cs
@@ -76,6 +76,7 @@ public bool Run(ConsoleTheme theme, int right, int top)
break;
case ConsoleKey.F10:
case ConsoleKey.Escape:
+ case ConsoleKey.Applications:
done = true;
break;
}
diff --git a/ConsoleUI/Toolkit/ConsoleScreen.cs b/ConsoleUI/Toolkit/ConsoleScreen.cs
index 856d0cf0d4..04060f9524 100644
--- a/ConsoleUI/Toolkit/ConsoleScreen.cs
+++ b/ConsoleUI/Toolkit/ConsoleScreen.cs
@@ -18,7 +18,7 @@ protected ConsoleScreen()
"F10", MenuTip(),
() => mainMenu != null
);
- AddBinding(Keys.F10, (object sender, ConsoleTheme theme) => {
+ AddBinding(new ConsoleKeyInfo[] {Keys.F10, Keys.Apps}, (object sender, ConsoleTheme theme) => {
bool val = true;
if (mainMenu != null) {
DrawSelectedHamburger(theme);
diff --git a/ConsoleUI/Toolkit/Keys.cs b/ConsoleUI/Toolkit/Keys.cs
index 5f39473767..77d9081540 100644
--- a/ConsoleUI/Toolkit/Keys.cs
+++ b/ConsoleUI/Toolkit/Keys.cs
@@ -74,6 +74,13 @@ public static class Keys {
(System.Char)0, ConsoleKey.F10, false, false, false
);
+ ///
+ /// Representation of Apps for key bindings
+ ///
+ public static readonly ConsoleKeyInfo Apps = new ConsoleKeyInfo(
+ (System.Char)0, ConsoleKey.Applications, false, false, false
+ );
+
///
/// Representation of down arrow for key bindings
///
diff --git a/ConsoleUI/Toolkit/ScreenContainer.cs b/ConsoleUI/Toolkit/ScreenContainer.cs
index a15c7de74f..efb10c2e77 100644
--- a/ConsoleUI/Toolkit/ScreenContainer.cs
+++ b/ConsoleUI/Toolkit/ScreenContainer.cs
@@ -75,6 +75,18 @@ public void AddBinding(ConsoleKeyInfo k, KeyAction a)
}
}
+ ///
+ /// Add custom key bindings
+ ///
+ /// Keys to bind
+ /// Action to bind to key
+ public void AddBinding(IEnumerable keys, KeyAction a)
+ {
+ foreach (ConsoleKeyInfo k in keys) {
+ AddBinding(k, a);
+ }
+ }
+
///
/// Add a screen tip to show in the FooterBg
///
@@ -247,7 +259,7 @@ private void Blur(ScreenObject source, bool forward)
} while (!objects[focusIndex].Focusable());
}
}
-
+
private bool done = false;
private List objects = new List();
diff --git a/GUI/Controls/ManageMods.Designer.cs b/GUI/Controls/ManageMods.Designer.cs
index 7ca3a52d93..b610ee6784 100644
--- a/GUI/Controls/ManageMods.Designer.cs
+++ b/GUI/Controls/ManageMods.Designer.cs
@@ -112,6 +112,7 @@ private void InitializeComponent()
this.menuStrip2.Location = new System.Drawing.Point(0, 0);
this.menuStrip2.Name = "menuStrip2";
this.menuStrip2.Size = new System.Drawing.Size(5876, 48);
+ this.menuStrip2.TabStop = true;
this.menuStrip2.TabIndex = 4;
this.menuStrip2.Text = "menuStrip2";
//
diff --git a/GUI/Controls/ManageMods.cs b/GUI/Controls/ManageMods.cs
index 189f898bcd..60f68497f7 100644
--- a/GUI/Controls/ManageMods.cs
+++ b/GUI/Controls/ManageMods.cs
@@ -643,6 +643,11 @@ private void ModList_KeyDown(object sender, KeyEventArgs e)
}
}
break;
+
+ case Keys.Apps:
+ ShowModContextMenu();
+ e.Handled = true;
+ break;
}
}
@@ -908,23 +913,31 @@ private void ModList_MouseDown(object sender, MouseEventArgs e)
{
var rowIndex = ModGrid.HitTest(e.X, e.Y).RowIndex;
- // Ignore header column to prevent errors.
+ // Ignore header column to prevent errors
if (rowIndex != -1 && e.Button == MouseButtons.Right)
{
- // Detect the clicked cell and select the row.
+ // Detect the clicked cell and select the row
ModGrid.ClearSelection();
ModGrid.Rows[rowIndex].Selected = true;
- // Show the context menu.
- ModListContextMenuStrip.Show(ModGrid, new Point(e.X, e.Y));
-
- // Set the menu options.
- var guiMod = (GUIMod)ModGrid.Rows[rowIndex].Tag;
+ // Show the context menu
+ ShowModContextMenu();
+ }
+ }
+ private bool ShowModContextMenu()
+ {
+ var guiMod = SelectedModule;
+ if (guiMod != null)
+ {
+ ModListContextMenuStrip.Show(Cursor.Position);
+ // Set the menu options
downloadContentsToolStripMenuItem.Enabled = !guiMod.ToModule().IsMetapackage && !guiMod.IsCached;
purgeContentsToolStripMenuItem.Enabled = !guiMod.ToModule().IsMetapackage && guiMod.IsCached;
reinstallToolStripMenuItem.Enabled = guiMod.IsInstalled && !guiMod.IsAutodetected;
+ return true;
}
+ return false;
}
private void ModList_Resize(object sender, EventArgs e)
diff --git a/GUI/Controls/ModInfo.cs b/GUI/Controls/ModInfo.cs
index 39d0595036..2abbc74a8e 100644
--- a/GUI/Controls/ModInfo.cs
+++ b/GUI/Controls/ModInfo.cs
@@ -118,6 +118,17 @@ private void LinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs
Util.HandleLinkClicked((sender as LinkLabel).Text, e);
}
+ private void LinkLabel_KeyDown(object sender, KeyEventArgs e)
+ {
+ switch (e.KeyCode)
+ {
+ case Keys.Apps:
+ Util.LinkContextMenu((sender as LinkLabel).Text);
+ e.Handled = true;
+ break;
+ }
+ }
+
private void UpdateModInfo(GUIMod gui_module)
{
CkanModule module = gui_module.ToModule();
@@ -254,6 +265,7 @@ private void AddResourceLink(string label, Uri link)
Text = link.ToString(),
};
llbl.LinkClicked += new LinkLabelLinkClickedEventHandler(LinkLabel_LinkClicked);
+ llbl.KeyDown += new KeyEventHandler(LinkLabel_KeyDown);
int row = MetaDataLowerLayoutPanel.RowCount;
MetaDataLowerLayoutPanel.Controls.Add(lbl, 0, row);
MetaDataLowerLayoutPanel.Controls.Add(llbl, 1, row);
diff --git a/GUI/Dialogs/AboutDialog.Designer.cs b/GUI/Dialogs/AboutDialog.Designer.cs
index 528c12ba04..1e21bce130 100644
--- a/GUI/Dialogs/AboutDialog.Designer.cs
+++ b/GUI/Dialogs/AboutDialog.Designer.cs
@@ -87,6 +87,7 @@ private void InitializeComponent()
this.licenseLinkLabel.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.licenseLinkLabel.UseCompatibleTextRendering = true;
this.licenseLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel_LinkClicked);
+ this.licenseLinkLabel.KeyDown += new System.Windows.Forms.KeyEventHandler(this.linkLabel_KeyDown);
//
// authorsLabel
//
@@ -108,6 +109,7 @@ private void InitializeComponent()
this.authorsLinkLabel.TabStop = true;
this.authorsLinkLabel.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.authorsLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel_LinkClicked);
+ this.authorsLinkLabel.KeyDown += new System.Windows.Forms.KeyEventHandler(this.linkLabel_KeyDown);
//
// sourceLabel
//
@@ -129,6 +131,7 @@ private void InitializeComponent()
this.sourceLinkLabel.TabStop = true;
this.sourceLinkLabel.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.sourceLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel_LinkClicked);
+ this.sourceLinkLabel.KeyDown += new System.Windows.Forms.KeyEventHandler(this.linkLabel_KeyDown);
//
// forumthreadLabel
//
@@ -151,6 +154,7 @@ private void InitializeComponent()
this.forumthreadLinkLabel.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.forumthreadLinkLabel.UseCompatibleTextRendering = true;
this.forumthreadLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel_LinkClicked);
+ this.forumthreadLinkLabel.KeyDown += new System.Windows.Forms.KeyEventHandler(this.linkLabel_KeyDown);
//
// homepageLabel
//
@@ -172,6 +176,7 @@ private void InitializeComponent()
this.homepageLinkLabel.TabStop = true;
this.homepageLinkLabel.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.homepageLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel_LinkClicked);
+ this.homepageLinkLabel.KeyDown += new System.Windows.Forms.KeyEventHandler(this.linkLabel_KeyDown);
//
// AboutDialog
//
diff --git a/GUI/Dialogs/AboutDialog.cs b/GUI/Dialogs/AboutDialog.cs
index 9e74d64d94..ce09e36761 100644
--- a/GUI/Dialogs/AboutDialog.cs
+++ b/GUI/Dialogs/AboutDialog.cs
@@ -17,5 +17,17 @@ private void linkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs
string url = (sender as LinkLabel).Text;
Util.HandleLinkClicked(url, e);
}
+
+ private void linkLabel_KeyDown(object sender, KeyEventArgs e)
+ {
+ switch (e.KeyCode)
+ {
+ case Keys.Apps:
+ Util.LinkContextMenu((sender as LinkLabel).Text);
+ e.Handled = true;
+ break;
+ }
+ }
+
}
}
diff --git a/GUI/Dialogs/ManageGameInstancesDialog.Designer.cs b/GUI/Dialogs/ManageGameInstancesDialog.Designer.cs
index f97c61dbfb..3dd123bf05 100644
--- a/GUI/Dialogs/ManageGameInstancesDialog.Designer.cs
+++ b/GUI/Dialogs/ManageGameInstancesDialog.Designer.cs
@@ -77,6 +77,7 @@ private void InitializeComponent()
this.GameInstancesListView.SelectedIndexChanged += new System.EventHandler(this.GameInstancesListView_SelectedIndexChanged);
this.GameInstancesListView.DoubleClick += new System.EventHandler(this.GameInstancesListView_DoubleClick);
this.GameInstancesListView.MouseClick += new System.Windows.Forms.MouseEventHandler(this.GameInstancesListView_Click);
+ this.GameInstancesListView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GameInstancesListView_KeyDown);
//
// InstanceListContextMenuStrip
//
diff --git a/GUI/Dialogs/ManageGameInstancesDialog.cs b/GUI/Dialogs/ManageGameInstancesDialog.cs
index 59dacd0b03..e49cd63db9 100644
--- a/GUI/Dialogs/ManageGameInstancesDialog.cs
+++ b/GUI/Dialogs/ManageGameInstancesDialog.cs
@@ -232,6 +232,17 @@ private void GameInstancesListView_Click(object sender, MouseEventArgs e)
}
}
+ private void GameInstancesListView_KeyDown(object sender, KeyEventArgs e)
+ {
+ switch (e.KeyCode)
+ {
+ case Keys.Apps:
+ InstanceListContextMenuStrip.Show(Cursor.Position);
+ e.Handled = true;
+ break;
+ }
+ }
+
private void OpenDirectoryMenuItem_Click(object sender, EventArgs e)
{
string path = _manager.Instances[(string) GameInstancesListView.SelectedItems[0].Tag].GameDir();