Skip to content

Commit ac6a0a8

Browse files
author
tznind
committed
Make clicking Button nicer and suppress native hover behaviours
1 parent ad698bb commit ac6a0a8

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/Design.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,13 @@ public Design CreateSubControlDesign(string name, View subView)
225225
tf.MouseEvent += (s,e)=>this.SuppressNativeClickEvents(s,e);
226226
}
227227

228+
if (subView is Button btn)
229+
{
230+
// prevent control from responding to events
231+
btn.MouseEvent += (s, e) => this.SuppressNativeClickEvents(s, e, true);
232+
btn.MouseEnter += (s, e) => e.Cancel = true;
233+
}
234+
228235
if (subView.GetType().IsGenericType(typeof(LinearRange<>)))
229236
{
230237
// TODO: Does not seem to work
@@ -578,6 +585,10 @@ private void SuppressNativeClickEvents(object? sender, Mouse obj, bool alsoSuppr
578585
if (alsoSuppressClick)
579586
{
580587
obj.Handled = true;
588+
if(sender is View v && obj.Flags == MouseFlags.LeftButtonClicked)
589+
{
590+
v.SetFocus();
591+
}
581592
}
582593
else
583594
{

0 commit comments

Comments
 (0)