From 6b7938fea1c7adeafc75cde5d414dba4f338bf86 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 16 May 2025 17:11:34 -0500 Subject: [PATCH] Add mousewheel event to edge Level/EXP Scroll up Level once to increase level, scroll down EXP to be 1 exp from level up. Apply the same mousewheel events to Friendship, IVs/EVs/AVs/GVs, with EVs being increments of 4. I don't think it's worth overriding keypress arrow up and down to do the same. --- PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs | 4 ++++ PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs | 9 +++++++++ PKHeX.WinForms/Util/WinFormsUtil.cs | 16 ++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index c7c470351..ebc898947 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -76,6 +76,10 @@ public PKMEditor() // Controls contained in a TabPage are not created until the tab page is shown // Any data bindings in these controls are not activated until the tab page is shown. FlickerInterface(); + + TB_EXP.MouseWheel += WinFormsUtil.MouseWheelIncrement1; + TB_Level.MouseWheel += WinFormsUtil.MouseWheelIncrement1; + TB_Friendship.MouseWheel += WinFormsUtil.MouseWheelIncrement1; } private sealed class ValidationRequiredSet(Control[] controls, Func shouldCheck, Func isState) diff --git a/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs index dc05ced3a..81def0987 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs @@ -23,6 +23,15 @@ public StatEditor() TB_BST.ResetForeColor(); TB_IVTotal.ForeColor = TB_EVTotal.ForeColor = MT_EVs[0].ForeColor; + + foreach (var iv in MT_IVs) + iv.MouseWheel += WinFormsUtil.MouseWheelIncrement1; + foreach (var ev in MT_EVs) + ev.MouseWheel += WinFormsUtil.MouseWheelIncrement4; + foreach (var av in MT_AVs) + av.MouseWheel += WinFormsUtil.MouseWheelIncrement1; + foreach (var gv in MT_GVs) + gv.MouseWheel += WinFormsUtil.MouseWheelIncrement1; } public Color EVsInvalid { get; set; } = Color.Red; diff --git a/PKHeX.WinForms/Util/WinFormsUtil.cs b/PKHeX.WinForms/Util/WinFormsUtil.cs index 06de96573..21c4b232f 100644 --- a/PKHeX.WinForms/Util/WinFormsUtil.cs +++ b/PKHeX.WinForms/Util/WinFormsUtil.cs @@ -205,6 +205,22 @@ public static void RemoveDropCB(object? sender, KeyEventArgs e) ((ComboBox)sender).DroppedDown = false; } + public static void MouseWheelIncrement1(object? sender, MouseEventArgs e) => Adjust(sender, e, 1); + public static void MouseWheelIncrement4(object? sender, MouseEventArgs e) => Adjust(sender, e, 4); + + private static void Adjust(object? sender, MouseEventArgs e, uint increment) + { + if (sender is not TextBoxBase tb) + return; + var text = tb.Text; + var value = Util.ToUInt32(text); + if (e.Delta > 0) + value += increment; + else if (value >= increment) + value -= increment; + tb.Text = value.ToString(); + } + /// /// Iterates the Control's child controls recursively to obtain all controls of the specified type. ///