Rename events to be DOM names (fix #41)

This commit is contained in:
Frank A. Krueger 2017-12-10 15:07:33 -08:00
parent 7d9d4e4265
commit 8a27f336bd
19 changed files with 71 additions and 59 deletions

View File

@ -59,7 +59,7 @@ namespace Ooui.Forms
{
ClassName = "btn btn-default"
};
_cancelButton.Clicked += (s, e) => SetResult(false);
_cancelButton.Click += (s, e) => SetResult(false);
footer.AppendChild(_cancelButton);
@ -70,7 +70,7 @@ namespace Ooui.Forms
ClassName = "btn btn-default"
};
_acceptButton.Clicked += (s, e) => SetResult(true);
_acceptButton.Click += (s, e) => SetResult(true);
footer.AppendChild(_acceptButton);
}
@ -90,23 +90,23 @@ namespace Ooui.Forms
{
add
{
_closeButton.Clicked += value;
_closeButton.Click += value;
if(_cancelButton != null)
_cancelButton.Clicked += value;
_cancelButton.Click += value;
if(_acceptButton != null)
_acceptButton.Clicked += value;
_acceptButton.Click += value;
}
remove
{
_closeButton.Clicked -= value;
_closeButton.Click -= value;
if (_cancelButton != null)
_cancelButton.Clicked -= value;
_cancelButton.Click -= value;
if (_acceptButton != null)
_acceptButton.Clicked -= value;
_acceptButton.Click -= value;
}
}
public Element Element { get; private set; }

View File

@ -22,7 +22,7 @@ namespace Ooui.Forms.Renderers
protected override void Dispose (bool disposing)
{
if (Control != null) {
Control.Clicked -= OnButtonTouchUpInside;
Control.Click -= OnButtonTouchUpInside;
}
base.Dispose (disposing);
@ -44,7 +44,7 @@ namespace Ooui.Forms.Renderers
_buttonTextColorDefaultHighlighted = Ooui.Colors.Black;
_buttonTextColorDefaultDisabled = Ooui.Colors.Black;
Control.Clicked += OnButtonTouchUpInside;
Control.Click += OnButtonTouchUpInside;
}
UpdateText ();

View File

@ -31,8 +31,8 @@ namespace Ooui.Forms.Renderers
Type = InputType.Date,
};
entry.Inputted += OnStarted;
entry.Changed += OnEnded;
//entry.Input += OnStarted;
entry.Change += OnEnded;
SetNativeControl (entry);
}
@ -100,8 +100,8 @@ namespace Ooui.Forms.Renderers
if (disposing) {
if (Control != null) {
Control.Inputted -= OnStarted;
Control.Changed -= OnEnded;
//Control.Input -= OnStarted;
Control.Change -= OnEnded;
}
}

View File

@ -25,9 +25,9 @@ namespace Ooui.Forms.Renderers
if (disposing) {
if (Control != null) {
Control.Inputted -= HandleChanged;
Control.Input -= HandleChanged;
//Control.Started -= OnStarted;
Control.Changed -= OnEnded;
Control.Change -= OnEnded;
}
}
@ -46,9 +46,9 @@ namespace Ooui.Forms.Renderers
ClassName = "form-control"
});
Control.Inputted += HandleChanged;
Control.Input += HandleChanged;
//Control.Started += OnStarted;
Control.Changed += OnEnded;
Control.Change += OnEnded;
}
UpdateText ();

View File

@ -6,7 +6,7 @@ using Xamarin.Forms;
namespace Ooui.Forms.Renderers
{
public class EntryRenderer : ViewRenderer<Entry, Ooui.Input>
public class EntryRenderer : ViewRenderer<Entry, Ooui.TextInput>
{
Ooui.Color _defaultTextColor;
bool _disposed;
@ -32,8 +32,8 @@ namespace Ooui.Forms.Renderers
if (disposing) {
if (Control != null) {
//Control.Inputted -= OnEditingBegan;
Control.Inputted -= OnEditingChanged;
Control.Changed -= OnEditingEnded;
Control.Input -= OnEditingChanged;
Control.Change -= OnEditingEnded;
}
}
@ -48,7 +48,7 @@ namespace Ooui.Forms.Renderers
return;
if (Control == null) {
var textField = new Ooui.Input (InputType.Text);
var textField = new Ooui.TextInput ();
SetNativeControl (textField);
Debug.Assert (Control != null, "Control != null");
@ -57,10 +57,10 @@ namespace Ooui.Forms.Renderers
_defaultTextColor = Colors.Black;
textField.Inputted += OnEditingChanged;
textField.Input += OnEditingChanged;
//textField.EditingDidBegin += OnEditingBegan;
textField.Changed += OnEditingEnded;
textField.Change += OnEditingEnded;
}
UpdatePlaceholder ();

View File

@ -14,7 +14,7 @@ namespace Ooui.Forms.Renderers
protected override void Dispose (bool disposing)
{
if (disposing)
Control.Changed -= OnControlValueChanged;
Control.Change -= OnControlValueChanged;
base.Dispose (disposing);
}
@ -30,7 +30,7 @@ namespace Ooui.Forms.Renderers
input.SetAttribute ("data-toggle", "toggle");
SetNativeControl (input);
input.Call ("$.bootstrapToggle");
Control.Changed += OnControlValueChanged;
Control.Change += OnControlValueChanged;
}
Control.IsChecked = Element.IsToggled;

View File

@ -25,12 +25,12 @@ namespace Ooui
set => SetProperty (ref hidden, value, "hidden");
}
public event TargetEventHandler Clicked {
public event TargetEventHandler Click {
add => AddEventListener ("click", value);
remove => RemoveEventListener ("click", value);
}
public event TargetEventHandler DoubleClicked {
public event TargetEventHandler DoubleClick {
add => AddEventListener ("dblclick", value);
remove => RemoveEventListener ("dblclick", value);
}
@ -40,7 +40,7 @@ namespace Ooui
remove => RemoveEventListener ("keydown", value);
}
public event TargetEventHandler KeyPressed {
public event TargetEventHandler KeyPress {
add => AddEventListener ("keypress", value);
remove => RemoveEventListener ("keypress", value);
}
@ -55,17 +55,17 @@ namespace Ooui
remove => RemoveEventListener ("mousedown", value);
}
public event TargetEventHandler MouseEntered {
public event TargetEventHandler MouseEnter {
add => AddEventListener ("mouseenter", value);
remove => RemoveEventListener ("mouseenter", value);
}
public event TargetEventHandler MouseLeft {
public event TargetEventHandler MouseLeave {
add => AddEventListener ("mouseleave", value);
remove => RemoveEventListener ("mouseleave", value);
}
public event TargetEventHandler MouseMoved {
public event TargetEventHandler MouseMove {
add => AddEventListener ("mousemove", value);
remove => RemoveEventListener ("mousemove", value);
}
@ -85,7 +85,7 @@ namespace Ooui
remove => RemoveEventListener ("mouseup", value);
}
public event TargetEventHandler Wheeled {
public event TargetEventHandler Wheel {
add => AddEventListener ("wheel", value);
remove => RemoveEventListener ("wheel", value);
}

View File

@ -22,7 +22,7 @@ namespace Ooui
set => SetProperty (ref enctype, value ?? "", "enctype");
}
public event TargetEventHandler Submitted {
public event TargetEventHandler Submit {
add => AddEventListener ("submit", value);
remove => RemoveEventListener ("submit", value);
}

View File

@ -30,16 +30,11 @@ namespace Ooui
}
}
public event TargetEventHandler Changed {
public event TargetEventHandler Change {
add => AddEventListener ("change", value);
remove => RemoveEventListener ("change", value);
}
public event TargetEventHandler Inputted {
add => AddEventListener ("input", value);
remove => RemoveEventListener ("input", value);
}
string placeholder = "";
public string Placeholder {
get => placeholder;
@ -77,7 +72,7 @@ namespace Ooui
: base ("input")
{
// Subscribe to the change event so we always get up-to-date values
Changed += (s, e) => {};
Change += (s, e) => {};
}
public Input (InputType type)

View File

@ -10,12 +10,12 @@ namespace Ooui
set => SetProperty (ref val, value ?? "", "value");
}
public event TargetEventHandler Changed {
public event TargetEventHandler Change {
add => AddEventListener ("change", value);
remove => RemoveEventListener ("change", value);
}
public event TargetEventHandler Inputted {
public event TargetEventHandler Input {
add => AddEventListener ("input", value);
remove => RemoveEventListener ("input", value);
}
@ -24,7 +24,7 @@ namespace Ooui
: base ("select")
{
// Subscribe to the change event so we always get up-to-date values
Changed += (s, e) => { };
Change += (s, e) => { };
}
public void AddOption (string label, string value)

View File

@ -4,12 +4,12 @@ namespace Ooui
{
public class TextArea : FormControl
{
public event TargetEventHandler Changed {
public event TargetEventHandler Change {
add => AddEventListener ("change", value);
remove => RemoveEventListener ("change", value);
}
public event TargetEventHandler Inputted {
public event TargetEventHandler Input {
add => AddEventListener ("input", value);
remove => RemoveEventListener ("input", value);
}
@ -36,7 +36,7 @@ namespace Ooui
: base ("textarea")
{
// Subscribe to the change event so we always get up-to-date values
Changed += (s, e) => {};
Change += (s, e) => {};
}
public TextArea (string text)

17
Ooui/TextInput.cs Normal file
View File

@ -0,0 +1,17 @@
using System;
namespace Ooui
{
public class TextInput : Input
{
public event TargetEventHandler Input {
add => AddEventListener ("input", value);
remove => RemoveEventListener ("input", value);
}
public TextInput ()
: base (InputType.Text)
{
}
}
}

View File

@ -21,7 +21,7 @@ namespace AspNetCoreMvc.Controllers
var head = new Heading { Text = "Click away!" };
var label = new Label { Text = "0" };
var btn = new Button { Text = "Increase" };
btn.Clicked += (sender, e) => {
btn.Click += (sender, e) => {
count++;
label.Text = count.ToString ();
};

View File

@ -49,7 +49,7 @@ class Program
// Add some logic to it
var count = 0;
button.Clicked += (s, e) => {
button.Click += (s, e) => {
count++;
button.Text = $"Clicked {count} times";
};
@ -81,7 +81,7 @@ Button MakeButton()
{
var button = new Button("Click me!");
var count = 0;
button.Clicked += (s, e) => {
button.Click += (s, e) => {
count++;
button.Text = $"Clicked {count} times";
};

View File

@ -14,7 +14,7 @@ namespace Samples
};
button.Style.MarginTop = "2em";
var count = 0;
button.Clicked += (s, e) => {
button.Click += (s, e) => {
count++;
button.Text = $"Clicked {count} times";
};

View File

@ -27,7 +27,7 @@ namespace Samples
};
var context = canvas.GetContext2D ();
canvas.Clicked += (s, e) => {
canvas.Click += (s, e) => {
var radius = 10;
context.BeginPath ();
if (toolSel.Value == "box") {
@ -47,7 +47,7 @@ namespace Samples
Type = ButtonType.Submit,
ClassName = "btn btn-danger",
};
clearbtn.Clicked += (s, e) => {
clearbtn.Click += (s, e) => {
context.ClearRect (0, 0, canvas.Width, canvas.Height);
};
clearbtn.Style.Display = "block";

View File

@ -66,19 +66,19 @@ namespace Samples
if (string.IsNullOrWhiteSpace (input.Value))
return;
var item = new Item (input.Value);
item.Clicked += (s, e) => {
item.Click += (s, e) => {
item.IsDone = !item.IsDone;
};
items.InsertBefore (item, items.FirstChild);
input.Value = "";
}
addbtn.Clicked += (s, e) => {
addbtn.Click += (s, e) => {
AddItem ();
};
inputForm.Submitted += (s, e) => {
inputForm.Submit += (s, e) => {
AddItem ();
};
clearbtn.Clicked += (s, e) => {
clearbtn.Click += (s, e) => {
var toremove = new List<Node> ();
foreach (Item i in items.Children) {
if (i.IsDone) toremove.Add (i);

View File

@ -42,7 +42,7 @@ namespace Tests
listened = listened || (m.MessageType == MessageType.Listen);
};
Assert.IsFalse (listened);
b.Clicked += (s, e) => {
b.Click += (s, e) => {
clicked = true;
};
Assert.IsTrue (listened);

View File

@ -52,7 +52,7 @@ namespace Tests
var b = new Button ();
p.AppendChild (b);
var clicked = false;
b.Clicked += (s, e) => {
b.Click += (s, e) => {
clicked = true;
};
p.Receive (Message.Event (b.Id, "click"));