Skip to content

Commit a8769e4

Browse files
committed
fix: decouple Component pressed state from hover
After Avalonia 11.3, PointerExited fires during implicit pointer capture, so IsHover flips to false mid-drag. Tying IsXxxButtonPressed to IsHover made the FunctionBar separator, parameter panel separator and sliders stop following once the cursor left the control's bounds. Make the press flags per-instance and drop the IsHover coupling so press state reflects whether this component itself was pressed, independent of where the cursor currently is.
1 parent eda6ded commit a8769e4

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

TuneLab/GUI/Components/Component.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ internal class Component : Control
2121
public ModifierKeys Modifiers => mLastKeyModifiers;
2222
public Avalonia.Point MousePosition => mLastMousePosition;
2323
public bool IsHover => mHoverComponent == this;
24-
public bool IsPrimaryButtonPressed => IsHover && mIsPrimaryButtonPressed;
25-
public bool IsMiddleButtonPressed => IsHover && mIsMiddleButtonPressed;
26-
public bool IsSecondaryButtonPressed => IsHover && mIsSecondaryButtonPressed;
27-
public bool IsPressed => IsHover && (mIsPrimaryButtonPressed || mIsMiddleButtonPressed || mIsSecondaryButtonPressed);
24+
public bool IsPrimaryButtonPressed => mIsPrimaryButtonPressed;
25+
public bool IsMiddleButtonPressed => mIsMiddleButtonPressed;
26+
public bool IsSecondaryButtonPressed => mIsSecondaryButtonPressed;
27+
public bool IsPressed => mIsPrimaryButtonPressed || mIsMiddleButtonPressed || mIsSecondaryButtonPressed;
2828
public long DoubleClickInterval { get; set; } = 300;
2929

3030
public Component()
@@ -230,9 +230,9 @@ void CallMouseLeave(MouseLeaveEventArgs e)
230230
}
231231

232232
static Component? mHoverComponent = null;
233-
static bool mIsPrimaryButtonPressed = false;
234-
static bool mIsMiddleButtonPressed = false;
235-
static bool mIsSecondaryButtonPressed = false;
233+
bool mIsPrimaryButtonPressed = false;
234+
bool mIsMiddleButtonPressed = false;
235+
bool mIsSecondaryButtonPressed = false;
236236
static Stopwatch mStopwatch = new();
237237
static long mLastClickTime = 0;
238238
static Avalonia.Point mLastClickPosition;

0 commit comments

Comments
 (0)