Replies: 2 comments
-
Nice idea. I wonder if this could be more generic though, and support any var tree = new TreeView() { ... };
...
var result = InputBox.Query("Select from Tree", tree);
MessageBox.Query("You selected..", result);
// Above is same as:
MessageBox.Query("You selected..", tree.Text); (I think the |
Beta Was this translation helpful? Give feedback.
-
I think a basic InputBox would be nice to have, it is handy and would lower the bar of entry. Given we have I think that we should support (optional) Label text. The traditional input box supports both title and label and they have different roles.
https://www.w3schools.com/js/js_popup.asp I love the idea of making it slottable. Building on that idea, I think we should start with only public static method signature that matches other libraries (e.g. VB / Javascript). We can keep the 'slottable' backend private until we are sure the code design is finalised and then make public if there is benefit from it. Something like this: public class InputBox<T> : Dialog
{
private readonly Func<T> getter;
public T Result { get
{
return getter();
}
}
private InputBox(string title, string prompt, T defaultValue, View hosted, Func<T> getter)
{
this.getter = getter;
// TODO setup rest of view
}
public static string QueryString(string title, string prompt, string defaultValue)
{
var tf = new TextField();
var getter = ()=>tf.Text.ToString();
var box = new InputBox<string>(title, prompt, defaultValue, tf, getter);
Application.Run(box);
return box.Result;
}
public static DateTime QueryDate(string title, string prompt, DateTime defaultValue)
{
var df = new DateField();
var getter = () => df.Date;
var box = new InputBox<DateTime>(title, prompt, defaultValue, df, getter);
Application.Run(box);
return box.Result;
}
} |
Beta Was this translation helpful? Give feedback.
-
Would an
InputBox
be a desirable addition? I was looking for one myself.Here is a start, largely derived from UICatalog
TableEditor.EditCurrentCell
.Beta Was this translation helpful? Give feedback.
All reactions