diff --git a/Ooui/Form.cs b/Ooui/Form.cs new file mode 100644 index 0000000..5cde544 --- /dev/null +++ b/Ooui/Form.cs @@ -0,0 +1,17 @@ +using System; + +namespace Ooui +{ + public class Form : Element + { + public event EventHandler Submitted { + add => AddEventListener ("submit", value); + remove => RemoveEventListener ("submit", value); + } + + public Form () + : base ("form") + { + } + } +} diff --git a/Ooui/FormControl.cs b/Ooui/FormControl.cs index e98607e..7555d9f 100644 --- a/Ooui/FormControl.cs +++ b/Ooui/FormControl.cs @@ -16,6 +16,16 @@ namespace Ooui set => SetProperty (ref isDisabled, value, "disabled"); } + public Form Form { + get { + var p = ParentNode; + while (p != null && !(p is Form)) { + p = p.ParentNode; + } + return p as Form; + } + } + public FormControl (string tagName) : base (tagName) {