Skip to content

Commit

Permalink
Show mod context menu on menu key press
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Sep 5, 2021
1 parent 2a2b12e commit ef4ee26
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 7 deletions.
27 changes: 20 additions & 7 deletions GUI/Controls/ManageMods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,11 @@ private void ModList_KeyDown(object sender, KeyEventArgs e)
}
}
break;

case Keys.Apps:
ShowModContextMenu();
e.Handled = true;
break;
}
}

Expand Down Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions GUI/Controls/ModInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions GUI/Dialogs/AboutDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions GUI/Dialogs/AboutDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

}
}
1 change: 1 addition & 0 deletions GUI/Dialogs/ManageGameInstancesDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions GUI/Dialogs/ManageGameInstancesDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit ef4ee26

Please sign in to comment.