From 8fe076b29c3c67ddf556783ea468c41bc3db9a8a Mon Sep 17 00:00:00 2001 From: "Frank A. Krueger" Date: Sun, 8 Mar 2020 17:32:49 -0700 Subject: [PATCH] Add convenience constructors --- Ooui/Button.cs | 6 ++++++ Ooui/Div.cs | 10 +++++++++- Ooui/ListItem.cs | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Ooui/Button.cs b/Ooui/Button.cs index e11da52..8ba4bf1 100644 --- a/Ooui/Button.cs +++ b/Ooui/Button.cs @@ -22,6 +22,12 @@ namespace Ooui { Text = text; } + + public Button (string text, TargetEventHandler clickHandler) + : this (text) + { + Click += clickHandler; + } } [JsonConverter (typeof (StringEnumConverter))] diff --git a/Ooui/Div.cs b/Ooui/Div.cs index f9098c4..6e2cacf 100644 --- a/Ooui/Div.cs +++ b/Ooui/Div.cs @@ -12,7 +12,15 @@ namespace Ooui { } - public Div (params Element[] children) + public Div (params Node[] children) + : this () + { + foreach (var c in children) { + AppendChild (c); + } + } + + public Div (IEnumerable children) : this () { foreach (var c in children) { diff --git a/Ooui/ListItem.cs b/Ooui/ListItem.cs index 09d72bd..4d4329d 100644 --- a/Ooui/ListItem.cs +++ b/Ooui/ListItem.cs @@ -8,5 +8,11 @@ namespace Ooui : base ("li") { } + + public ListItem (string text) + : this () + { + Text = text; + } } }