Skip to content

Commit 6702e8b

Browse files
author
tznind
committed
Fix for CreateBars discarding all suppression
1 parent d654542 commit 6702e8b

1 file changed

Lines changed: 24 additions & 8 deletions

File tree

src/Design.cs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -569,19 +569,35 @@ private void SuppressNativeClickEvents(ColorPicker cp)
569569
cp.MouseEvent += (s, e) => this.SuppressNativeClickEvents(s, e, true);
570570
cp.MouseEnter += (s, e) => e.Cancel = true;
571571
cp.MouseBindings.Clear();
572+
573+
cp.SubViewAdded += (s,e)=> {
574+
if(e.SubView is ColorBar cb)
575+
{
576+
// Many things trigger CreateBars to happen which recreates all the hue/saturation/lightness etc bars
577+
// So we need to re-register our events each time they are created
578+
SuppressNativeClickEvents(cb);
579+
}
580+
};
572581

573-
foreach (var hue in cp.SubViews.OfType<ColorBar>())
582+
foreach (var cb in cp.SubViews.OfType<ColorBar>())
574583
{
575-
// prevent control from responding to events
576-
hue.MouseEvent += (s, e) => this.SuppressNativeClickEvents(s, e, true);
577-
hue.MouseEnter += (s, e) => e.Cancel = true;
578-
hue.MouseBindings.Clear();
579-
580-
// Prevent the color picker bar from activating as the wiring for drag changing hue bar etc is tied to activate
581-
hue.RemoveCommand(Command.Activate);
584+
SuppressNativeClickEvents(cb);
582585
}
583586
}
584587

588+
589+
private void SuppressNativeClickEvents(ColorBar cb)
590+
{
591+
// prevent control from responding to events
592+
cb.MouseEvent += (s, e) => this.SuppressNativeClickEvents(s, e, true);
593+
cb.MouseEnter += (s, e) => e.Cancel = true;
594+
cb.MouseBindings.Clear();
595+
596+
// Prevent the color picker bar from activating as the wiring for drag changing hue bar etc is tied to activate
597+
cb.RemoveCommand(Command.Activate);
598+
599+
}
600+
585601
private void SuppressNativeClickEvents(object? sender, Mouse obj, bool alsoSuppressClick = false)
586602
{
587603
if (alsoSuppressClick)

0 commit comments

Comments
 (0)