Skip to content

Commit 9246f0c

Browse files
committed
* ComboView event bubbling fix
* TextBox event bubbling fix
1 parent 4a1c9f0 commit 9246f0c

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/Myra/Graphics2D/UI/Selectors/ComboView.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,23 @@ public ComboView(string styleName = Stylesheet.DefaultStyleName)
133133

134134
_listView._parentCombo = this;
135135

136-
HorizontalAlignment = HorizontalAlignment.Left;
136+
if (MyraEnvironment.EventHandlingModel == EventHandlingStrategy.EventBubbling)
137+
_button.TouchDown += InternalStopPropagation;
138+
139+
HorizontalAlignment = HorizontalAlignment.Left;
137140
VerticalAlignment = VerticalAlignment.Top;
138141

139142
DropdownMaximumHeight = 300;
140143

141144
SetStyle(styleName);
142145
}
143146

144-
private void DesktopOnContextMenuClosed(object sender, GenericEventArgs<Widget> genericEventArgs)
147+
private void InternalStopPropagation(object sender, MyraEventArgs e)
148+
{
149+
e.StopPropagation();
150+
}
151+
152+
private void DesktopOnContextMenuClosed(object sender, GenericEventArgs<Widget> genericEventArgs)
145153
{
146154
// Unpress the button only if mouse is outside
147155
// As if it is inside, then it'll get unpressed naturally

src/Myra/Graphics2D/UI/Simple/TextBox.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,18 @@ public TextBox(string styleName = Stylesheet.DefaultStyleName)
336336
BlinkIntervalInMs = 450;
337337

338338
MouseCursor = MouseCursorType.IBeam;
339+
340+
if (MyraEnvironment.EventHandlingModel == EventHandlingStrategy.EventBubbling)
341+
this.TouchDoubleClick += TextBox_TouchDoubleClickStopPropagation;
339342
}
340-
341-
private void DeleteChars(int pos, int l)
343+
344+
private void TextBox_TouchDoubleClickStopPropagation(object sender, MyraEventArgs e)
345+
{
346+
e.StopPropagation();
347+
InputEventsManager.StopPropagation(InputEventType.TouchDown);
348+
}
349+
350+
private void DeleteChars(int pos, int l)
342351
{
343352
if (l == 0)
344353
return;
@@ -1185,7 +1194,6 @@ private void DesktopTouchDown(object sender, MyraEventArgs e)
11851194
_isTouchDown = true;
11861195
}
11871196

1188-
11891197
public override void OnTouchDoubleClick()
11901198
{
11911199
base.OnTouchDoubleClick();

0 commit comments

Comments
 (0)