Skip to content

Commit

Permalink
Setting e.Cancel = true in Splitter.PositionChanging event should can…
Browse files Browse the repository at this point in the history
…cel any changes
  • Loading branch information
cwensley committed Jul 6, 2023
1 parent 5c436ca commit 41d1e3b
Show file tree
Hide file tree
Showing 5 changed files with 245 additions and 200 deletions.
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

0 comments on commit 41d1e3b

Please sign in to comment.