2017-06-16 06:15:26 +00:00
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace Ooui
|
|
|
|
{
|
2017-06-16 06:21:20 +00:00
|
|
|
public class TextArea : FormControl
|
2017-06-16 06:15:26 +00:00
|
|
|
{
|
2017-12-10 23:07:33 +00:00
|
|
|
public event TargetEventHandler Change {
|
2017-06-16 06:15:26 +00:00
|
|
|
add => AddEventListener ("change", value);
|
|
|
|
remove => RemoveEventListener ("change", value);
|
|
|
|
}
|
|
|
|
|
2017-12-10 23:07:33 +00:00
|
|
|
public event TargetEventHandler Input {
|
2017-06-19 05:28:14 +00:00
|
|
|
add => AddEventListener ("input", value);
|
|
|
|
remove => RemoveEventListener ("input", value);
|
|
|
|
}
|
|
|
|
|
2017-06-16 06:56:30 +00:00
|
|
|
string val = "";
|
|
|
|
public string Value {
|
|
|
|
get => val;
|
|
|
|
set => SetProperty (ref val, value ?? "", "value");
|
2017-06-16 06:15:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int rows = 2;
|
|
|
|
public int Rows {
|
|
|
|
get => rows;
|
|
|
|
set => SetProperty (ref rows, value, "rows");
|
|
|
|
}
|
|
|
|
|
2017-06-16 06:17:21 +00:00
|
|
|
int cols = 20;
|
2017-06-16 06:15:26 +00:00
|
|
|
public int Columns {
|
|
|
|
get => cols;
|
|
|
|
set => SetProperty (ref cols, value, "cols");
|
|
|
|
}
|
|
|
|
|
|
|
|
public TextArea ()
|
|
|
|
: base ("textarea")
|
|
|
|
{
|
2017-06-24 20:34:47 +00:00
|
|
|
// Subscribe to the change event so we always get up-to-date values
|
2017-12-10 23:07:33 +00:00
|
|
|
Change += (s, e) => {};
|
2017-06-16 06:15:26 +00:00
|
|
|
}
|
2017-06-16 06:21:20 +00:00
|
|
|
|
|
|
|
public TextArea (string text)
|
|
|
|
: this ()
|
|
|
|
{
|
2017-11-26 20:18:33 +00:00
|
|
|
Value = text;
|
2017-06-16 06:21:20 +00:00
|
|
|
}
|
2017-06-24 20:34:47 +00:00
|
|
|
|
|
|
|
protected override bool TriggerEventFromMessage (Message message)
|
|
|
|
{
|
2017-11-26 20:18:33 +00:00
|
|
|
if (message.TargetId == Id && message.MessageType == MessageType.Event && (message.Key == "change" || message.Key == "input")) {
|
2017-06-24 21:52:34 +00:00
|
|
|
// Don't need to notify here because the base implementation will fire the event
|
|
|
|
val = message.Value != null ? Convert.ToString (message.Value) : "";
|
2017-06-24 20:34:47 +00:00
|
|
|
}
|
|
|
|
return base.TriggerEventFromMessage (message);
|
|
|
|
}
|
2017-06-16 06:15:26 +00:00
|
|
|
}
|
|
|
|
}
|