Myra - UI Library for the MonoGame

Hello Rei,
Thanks for the kind words about Myra.
I’ve refactoried that code a bit recently, so that method is now caled GetTopWidget(which describes what it does more accurately). Here how it looks:

		private Widget GetTopWidget(bool containsTouch)
		{
			for (var i = ChildrenCopy.Count - 1; i >= 0; --i)
			{
				var w = ChildrenCopy[i];
				if (w.Visible && w.Enabled &&
					(!containsTouch ||
					(containsTouch && w.Bounds.Contains(TouchPosition))))
				{
					return w;
				}
			}

			return null;
		}

So if containsTouch set to true, it’ll return any widget that contains mouse cursor(or touch position for devices). Hopefully that answers your question. :slight_smile:

p.s. Still right now, it’s not possible to have multiple windows and switch input focus beetween them. As any Window can be shown only in modal mode(see Window.ShowModal method). However method Window.Show will be added eventually.
Actually, thanks for the reminder, as I’ve created corresponding case: https://github.com/rds1983/Myra/issues/137

Ah! Okay, so it wasn’t a natively implemented feature after all. Your new method there seems like it’d do exactly what I was expecting. That would allow the sort of focus switching I was thinking about. Thanks for taking the time to answer my question.

Since it’s on my mind, I’ll take a moment to backseat program since I’ve been thinking about this. You probably already solved all these issues and are aware of them, but figured I’d throw it out there anyway.

It might be good to store a record of the most previously ‘touched/active’ widget and check that one first. My thought there is that it looks like there could be a scenario where two windows are overlapping which might cause a conflict.

Say window A and window B. Window B is visually overlayed half way over window A and is the current focus of the user. Then the mouse cursor enters into the intersection point of window A and B.

In that scenario, two widgets are viable return values in GetTopWidget(), but again only the first one iterated will returned(which may even be window A in this case, even though visually B overlays it).

An alternative would be that it checks what the current ‘touch focused’ widget is. If its bounds contain the touch, return that one. If they don’t, a new window is being touched. Set that new window as a the current active ‘touch focus’ and then return it instead.

The tricky thing is that you could still want a scenario in which window A becomes the new touch focus, but window B still has keyboard/input focus because the user hasen’t actually ‘clicked/touchedDown’ window A yet.

Also, rendering order is a thing. Rather than rendering in order of the observable collection, it might make sense to have a history of the order of previously focused widgets and render in that order instead. So if window A was the last window the user interacted with, it’s at the bottom of the list, followed by C, and finally B the currently active window.

Actually thinking out loud like this helps me a lot with my own ideas. Thanks again.

Anyway, i’ll stop rambling and presuming to code Myra in my head.

Probably if user clicks/touches a window, I’ll simply move it into the end of _widgets collection, so it’ll be returned first by GetTopWidget call.

Myra 0.9.6 is out: https://github.com/rds1983/Myra/releases/tag/0.9.6.184

1 Like

Myra 0.9.7 is out: https://github.com/rds1983/Myra/releases/tag/0.9.7.185

1 Like

Myra 0.9.8 is out: https://github.com/rds1983/Myra/releases/tag/0.9.8.188

Happy New Year!

4 Likes

Myra 0.9.9 is out: https://github.com/rds1983/Myra/releases/tag/0.9.9.198

2 Likes

New project announcement: Myra.Extended provides additional functionality for Myra. If you would like to contribute a Myra widget, feel free to PR it there: https://github.com/rds1983/Myra.Extended

Hi rds 1983

It seems that I can’t get running myra on linux. Everything works fine on Windows.

Kinds Regards
Andru

After almost 4 years of development, Myra 1.0 had been released: https://github.com/rds1983/Myra/releases/tag/1.0.0.204

Thanks everyone!

6 Likes

Congrats and well done for the milestone! :champagne: :sake:

1 Like

New Myra Release: https://github.com/rds1983/Myra/releases/tag/1.1.0.214

Damn, that was 7 months ago?

I totally went into hibernation for the second half of the year…

Yet Another Release:

1 Like

Any reason why when I change textbox’s textverticalalignment to centered the cursor does not also go in the same spot?

Probably a bug.

What is the proper way to render a scene to a control in Myra?

What is the difference between a SplitPane, StackPanel and Panel?

When should each be used?

By making a custom control. There’s a sample demonstrating that: Myra/samples/Myra.Samples.CustomWidgets at master · rds1983/Myra (github.com)

1 Like

Myra.Samples.SplitPaneContainer sample demonstrates what SplitPane is.
As for StackPanel & Panel, see the docs:
Basic Layout and Panel · rds1983/Myra Wiki (github.com)
StackPanel Layout · rds1983/Myra Wiki (github.com)