Skip to content

Commit

Permalink
Suppress Contents tab double click expand/collapse
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Sep 26, 2024
1 parent 15690d3 commit bf29c99
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
3 changes: 3 additions & 0 deletions GUI/Controls/ModInfoTabs/Contents.Designer.cs

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

30 changes: 28 additions & 2 deletions GUI/Controls/ModInfoTabs/Contents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ public void RefreshModContentsTree()

public event Action<GUIMod>? OnDownloadClick;

private GUIMod? selectedModule;
private CkanModule? currentModContentsModule;
private static GameInstanceManager? manager => Main.Instance?.Manager;

private GUIMod? selectedModule;
private CkanModule? currentModContentsModule;
private bool cancelExpandCollapse;

private void ContentsPreviewTree_NodeMouseDoubleClick(object? sender, TreeNodeMouseClickEventArgs? e)
{
if (e != null && manager?.CurrentInstance is GameInstance inst)
Expand All @@ -61,6 +63,30 @@ private void ContentsPreviewTree_NodeMouseDoubleClick(object? sender, TreeNodeMo
}
}

private void ContentsPreviewTree_MouseDown(object sender, MouseEventArgs e)
{
// Double click itself isn't cancellable, and it happens after expand/collapse anyway,
// so we have to detect it here and then cancel the main expand/collapse event
switch (e)
{
case {Clicks: > 1}:
cancelExpandCollapse = true;
break;
}
}

private void ContentsPreviewTree_BeforeExpandCollapse(object sender, TreeViewCancelEventArgs e)
{
switch (e)
{
case {Action: TreeViewAction.Expand
or TreeViewAction.Collapse} when cancelExpandCollapse:
e.Cancel = true;
cancelExpandCollapse = false;
break;
}
}

private void ContentsDownloadButton_Click(object? sender, EventArgs? e)
{
if (SelectedModule != null)
Expand Down

0 comments on commit bf29c99

Please sign in to comment.