Skip to content

Commit

Permalink
issue #16 work around
Browse files Browse the repository at this point in the history
  • Loading branch information
Seelge committed Nov 17, 2017
1 parent a62f5e5 commit 6eaff6a
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ https://github.com/Seelge/TrackballScroll/releases/latest
- Build the solution

###### Version history
- v4 prevents #16... sort of (middle clicks can be disabled if necessary using the tray menu).
- v3 feature #12: Allows to choose which X-buttons are used and saves the settings. Also changed versioning scheme to single numbers.
- v2.1.2 fixes #14. Compatibility with Windows 10 versions of 2017.
- v2.1.1 fixes issues #8, #9, #10. Instead of calculating the scaled coordinates, both original and scaled coordinates are memorized.
Expand Down
3 changes: 3 additions & 0 deletions TrackballScroll/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<setting name="preferAxis" serializeAs="String">
<value>True</value>
</setting>
<setting name="emulateMiddleButton" serializeAs="String">
<value>True</value>
</setting>
</TrackballScroll.Properties.Settings>
</userSettings>
</configuration>
11 changes: 10 additions & 1 deletion TrackballScroll/Properties/Resources.Designer.cs

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

5 changes: 4 additions & 1 deletion TrackballScroll/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<value>Prefer vertical/horizontal movement</value>
</data>
<data name="TextMessageBoxAbout" xml:space="preserve">
<value>TrackballScroll v3
<value>TrackballScroll v4
Copyright (c) 2016, 2017 Martin Seelge
Project URL: https://github.com/Seelge/TrackballScroll/

Expand All @@ -159,4 +159,7 @@ https://github.com/Seelge/TrackballScroll/blob/master/LICENSE</value>
<data name="TextButtonHookUseX2" xml:space="preserve">
<value>Use button X2</value>
</data>
<data name="TextButtonEmulateMiddleButton" xml:space="preserve">
<value>Emulate middle button when not scrolling</value>
</data>
</root>
12 changes: 12 additions & 0 deletions TrackballScroll/Properties/Settings.Designer.cs

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

3 changes: 3 additions & 0 deletions TrackballScroll/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
<Setting Name="preferAxis" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="emulateMiddleButton" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
15 changes: 15 additions & 0 deletions TrackballScroll/Sources/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static void Main()
private MenuItem itemUseX1;
private MenuItem itemUseX2;
private MenuItem itemPreferAxis;
private MenuItem itemEmulateMiddleButton;
private MouseHookTrackballScroll mouseHook;

public MainForm()
Expand Down Expand Up @@ -58,11 +59,17 @@ public MainForm()
itemPreferAxis.Checked = preferAxis;
mouseHook.preferAxisMovement = preferAxis;

var useMiddleButton = Properties.Settings.Default.emulateMiddleButton;
itemEmulateMiddleButton = new MenuItem(Properties.Resources.TextButtonEmulateMiddleButton, OnToggleEmulateMiddleButton);
itemEmulateMiddleButton.Checked = useMiddleButton;
mouseHook.emulateMiddleButton = useMiddleButton;

ContextMenu trayMenu = new ContextMenu();
trayMenu.MenuItems.Add(itemEnabled);
trayMenu.MenuItems.Add(itemUseX1);
trayMenu.MenuItems.Add(itemUseX2);
trayMenu.MenuItems.Add(itemPreferAxis);
trayMenu.MenuItems.Add(itemEmulateMiddleButton);
trayMenu.MenuItems.Add(Properties.Resources.TextButtonAbout, OnAbout);
trayMenu.MenuItems.Add(Properties.Resources.TextButtonExit, OnExit);

Expand Down Expand Up @@ -147,6 +154,14 @@ private void OnToggleAxis(object sender, EventArgs e)
Properties.Settings.Default.Save();
}

private void OnToggleEmulateMiddleButton(object sender, EventArgs e)
{
itemEmulateMiddleButton.Checked = !itemEmulateMiddleButton.Checked;
mouseHook.emulateMiddleButton = itemEmulateMiddleButton.Checked;
Properties.Settings.Default.emulateMiddleButton = itemEmulateMiddleButton.Checked;
Properties.Settings.Default.Save();
}

private void OnAbout(object sender, EventArgs e)
{
MessageBox.Show(Properties.Resources.TextMessageBoxAbout, Properties.Resources.TextTitle);
Expand Down
7 changes: 6 additions & 1 deletion TrackballScroll/Sources/MouseHookTrackballScroll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class MouseHookTrackballScroll : MouseHookBase, IDisposable
private System.Timers.Timer timer { get; set; }
public bool useX1 { get; set; }
public bool useX2 { get; set; }
public bool emulateMiddleButton { get; set; }

enum State
{
Expand Down Expand Up @@ -105,8 +106,12 @@ public override IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
{
break;
}
preventCallNextHookEx = true;
_state = State.NORMAL;
if(!emulateMiddleButton)
{
break;
}
preventCallNextHookEx = true;
WinAPI.INPUT[] input = new WinAPI.INPUT[2];
input[0].type = WinAPI.INPUT_MOUSE;
input[0].mi.dx = p.pt.x;
Expand Down
2 changes: 1 addition & 1 deletion TrackballScroll/TrackballScroll.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>3.0.0.%2a</ApplicationVersion>
<ApplicationVersion>4.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
Expand Down

0 comments on commit 6eaff6a

Please sign in to comment.