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

Setting e.Cancel = true in Splitter.PositionChanging event should cancel any changes #2517

Merged
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
8 changes: 6 additions & 2 deletions src/Eto.Mac/Forms/Controls/SplitterHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,13 @@ public override void DidResizeSubviews(NSNotification notification)
var mainFrame = h.Control.Frame;
if (mainFrame.Width <= 1 || mainFrame.Height <= 1)
return;
h.position = h.Control.IsVertical ? (int)subview.Frame.Width : (int)subview.Frame.Height;
var newPosition = h.Control.IsVertical ? (int)subview.Frame.Width : (int)subview.Frame.Height;
h.TriggerChangeStarted();
h.Callback.OnPositionChanged(h.Widget, EventArgs.Empty);
if (newPosition != h.position)
{
h.position = newPosition;
h.Callback.OnPositionChanged(h.Widget, EventArgs.Empty);
}
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/Eto.WinForms/Forms/Controls/SplitterHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ private void CheckSplitterPos(bool userMoved)
newPosition = lastPosition;
}

// always set splitter distance
Control.SplitterDistance = newPosition;

if (lastPosition != newPosition)
{
if (Control.IsHandleCreated)
Expand All @@ -170,9 +173,9 @@ private void CheckSplitterPos(bool userMoved)
position = newPosition;
Callback.OnPositionChanged(Widget, EventArgs.Empty);
}

Control.SplitterDistance = newPosition;
}


lastPosition = newPosition;

if (userMoved)
Expand Down
Loading