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

Skip mouse events of unloaded controls #454

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 13 additions & 1 deletion source/Components/AvalonDock/Controls/LayoutDocumentTabItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ protected virtual void OnModelChanged(DependencyPropertyChangedEventArgs e)
/// <inheritdoc />
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
if (!IsLoaded) return;

base.OnMouseLeftButtonDown(e);
CaptureMouse();
_allowDrag = false;
Expand All @@ -121,6 +123,8 @@ protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
/// <inheritdoc />
protected override void OnMouseMove(MouseEventArgs e)
{
if (!IsLoaded) return;

base.OnMouseMove(e);
_isMouseDown = Mouse.LeftButton == MouseButtonState.Pressed && _isMouseDown;
if (_isMouseDown)
Expand Down Expand Up @@ -160,6 +164,8 @@ protected override void OnMouseMove(MouseEventArgs e)
/// <inheritdoc />
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
{
if (!IsLoaded) return;

_isMouseDown = false;
_allowDrag = false;
if (IsMouseCaptured) ReleaseMouseCapture();
Expand All @@ -169,25 +175,31 @@ protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
/// <inheritdoc />
protected override void OnMouseLeave(MouseEventArgs e)
{
if (!IsLoaded) return;

base.OnMouseLeave(e);
_isMouseDown = false;
}

/// <inheritdoc />
protected override void OnMouseEnter(MouseEventArgs e)
{
if (!IsLoaded) return;

base.OnMouseEnter(e);
_isMouseDown = false;
}

/// <inheritdoc />
protected override void OnMouseDown(MouseButtonEventArgs e)
{
if (!IsLoaded) return;

if (LayoutItem != null && e.ChangedButton == MouseButton.Middle && LayoutItem.CloseCommand.CanExecute(null))
{
LayoutItem.CloseCommand.Execute(null);
}

base.OnMouseDown(e);
}

Expand Down