Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support mouse back/forward buttons #3655

Merged
merged 1 commit into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions GUI/Controls/ManageMods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1489,13 +1489,13 @@ private void NavSelectMod(GUIMod module)
navHistory.AddToHistory(module);
}

private void NavGoBackward()
public void NavGoBackward()
{
if (navHistory.CanNavigateBackward)
NavGoToMod(navHistory.NavigateBackward());
}

private void NavGoForward()
public void NavGoForward()
{
if (navHistory.CanNavigateForward)
NavGoToMod(navHistory.NavigateForward());
Expand Down
29 changes: 28 additions & 1 deletion GUI/Main/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace CKAN.GUI
{
public partial class Main : Form
public partial class Main : Form, IMessageFilter
{
private static readonly ILog log = LogManager.GetLogger(typeof(Main));

Expand Down Expand Up @@ -71,6 +71,8 @@ public Main(string[] cmdlineArgs, GameInstanceManager mgr, bool showConsole)
CultureInfo.DefaultThreadCurrentUICulture = Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(mainConfig.Language);
}

Application.AddMessageFilter(this);

InitializeComponent();

Instance = this;
Expand Down Expand Up @@ -336,6 +338,7 @@ protected override void OnFormClosed(FormClosedEventArgs e)
inst.playTime.Stop(inst.CkanDir());
}
}
Application.RemoveMessageFilter(this);
actuallyVisible = false;
base.OnFormClosed(e);
}
Expand Down Expand Up @@ -611,6 +614,30 @@ private void CompatibleGameVersionsToolStripMenuItem_Click(object sender, EventA
}
}

private const int WM_XBUTTONDOWN = 0x20b;
private const int MK_XBUTTON1 = 0x20;
private const int MK_XBUTTON2 = 0x40;

public bool PreFilterMessage(ref Message m)
{
switch (m.Msg)
{
case WM_XBUTTONDOWN:
switch (m.WParam.ToInt32() & 0xffff)
{
case MK_XBUTTON1:
ManageMods.NavGoBackward();
break;

case MK_XBUTTON2:
ManageMods.NavGoForward();
break;
}
break;
}
return false;
}

private void ManageMods_OnSelectedModuleChanged(GUIMod m)
{
ActiveModInfo = m;
Expand Down