mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 20:12:23 +00:00
* Adding in changes to deal with custom control types for loading from a GuiScreen, also adding in block text if a width for the element exists. Adding in Padding to some elements to give the developer some more options in styles. Adding in some changes to the textbox to deal with selecting a section of text. * Adding in a few changes to deal with propagation down the GuiControl tree, this was added to most events. Also, adding in the idea of a form and submit button to deal with keyboard controls when inside of a form. This gives simalar behavier to how forms work in the browser. * Adding in the enter key skip for the textbox.
48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using MonoGame.Extended.Input.InputListeners;
|
|
using Microsoft.Xna.Framework.Input;
|
|
|
|
namespace MonoGame.Extended.Gui.Controls
|
|
{
|
|
public class GuiForm : GuiStackPanel
|
|
{
|
|
public GuiForm()
|
|
: base() { }
|
|
|
|
public GuiForm(GuiSkin skin)
|
|
: base(skin) { }
|
|
|
|
public override bool OnKeyPressed(IGuiContext context, KeyboardEventArgs args)
|
|
{
|
|
if (args.Key == Keys.Tab)
|
|
{
|
|
var controls = FindControls<GuiControl>();
|
|
var index = controls.IndexOf(context.FocusedControl);
|
|
if (index > -1)
|
|
{
|
|
index++;
|
|
if (index >= controls.Count) index = 0;
|
|
context.SetFocus(controls[index]);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
if (args.Key == Keys.Enter)
|
|
{
|
|
var controls = FindControls<GuiSubmit>();
|
|
if (controls.Count > 0)
|
|
{
|
|
var submit = controls.FirstOrDefault();
|
|
submit.TriggerClicked();
|
|
return true;
|
|
}
|
|
}
|
|
return base.OnKeyPressed(context, args);
|
|
}
|
|
}
|
|
}
|