Rename events to be DOM names (fix #41)
This commit is contained in:
parent
7d9d4e4265
commit
8a27f336bd
|
@ -59,7 +59,7 @@ namespace Ooui.Forms
|
||||||
{
|
{
|
||||||
ClassName = "btn btn-default"
|
ClassName = "btn btn-default"
|
||||||
};
|
};
|
||||||
_cancelButton.Clicked += (s, e) => SetResult(false);
|
_cancelButton.Click += (s, e) => SetResult(false);
|
||||||
|
|
||||||
footer.AppendChild(_cancelButton);
|
footer.AppendChild(_cancelButton);
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ namespace Ooui.Forms
|
||||||
ClassName = "btn btn-default"
|
ClassName = "btn btn-default"
|
||||||
};
|
};
|
||||||
|
|
||||||
_acceptButton.Clicked += (s, e) => SetResult(true);
|
_acceptButton.Click += (s, e) => SetResult(true);
|
||||||
footer.AppendChild(_acceptButton);
|
footer.AppendChild(_acceptButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,23 +90,23 @@ namespace Ooui.Forms
|
||||||
{
|
{
|
||||||
add
|
add
|
||||||
{
|
{
|
||||||
_closeButton.Clicked += value;
|
_closeButton.Click += value;
|
||||||
|
|
||||||
if(_cancelButton != null)
|
if(_cancelButton != null)
|
||||||
_cancelButton.Clicked += value;
|
_cancelButton.Click += value;
|
||||||
|
|
||||||
if(_acceptButton != null)
|
if(_acceptButton != null)
|
||||||
_acceptButton.Clicked += value;
|
_acceptButton.Click += value;
|
||||||
}
|
}
|
||||||
remove
|
remove
|
||||||
{
|
{
|
||||||
_closeButton.Clicked -= value;
|
_closeButton.Click -= value;
|
||||||
|
|
||||||
if (_cancelButton != null)
|
if (_cancelButton != null)
|
||||||
_cancelButton.Clicked -= value;
|
_cancelButton.Click -= value;
|
||||||
|
|
||||||
if (_acceptButton != null)
|
if (_acceptButton != null)
|
||||||
_acceptButton.Clicked -= value;
|
_acceptButton.Click -= value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Element Element { get; private set; }
|
public Element Element { get; private set; }
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace Ooui.Forms.Renderers
|
||||||
protected override void Dispose (bool disposing)
|
protected override void Dispose (bool disposing)
|
||||||
{
|
{
|
||||||
if (Control != null) {
|
if (Control != null) {
|
||||||
Control.Clicked -= OnButtonTouchUpInside;
|
Control.Click -= OnButtonTouchUpInside;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.Dispose (disposing);
|
base.Dispose (disposing);
|
||||||
|
@ -44,7 +44,7 @@ namespace Ooui.Forms.Renderers
|
||||||
_buttonTextColorDefaultHighlighted = Ooui.Colors.Black;
|
_buttonTextColorDefaultHighlighted = Ooui.Colors.Black;
|
||||||
_buttonTextColorDefaultDisabled = Ooui.Colors.Black;
|
_buttonTextColorDefaultDisabled = Ooui.Colors.Black;
|
||||||
|
|
||||||
Control.Clicked += OnButtonTouchUpInside;
|
Control.Click += OnButtonTouchUpInside;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateText ();
|
UpdateText ();
|
||||||
|
|
|
@ -31,8 +31,8 @@ namespace Ooui.Forms.Renderers
|
||||||
Type = InputType.Date,
|
Type = InputType.Date,
|
||||||
};
|
};
|
||||||
|
|
||||||
entry.Inputted += OnStarted;
|
//entry.Input += OnStarted;
|
||||||
entry.Changed += OnEnded;
|
entry.Change += OnEnded;
|
||||||
|
|
||||||
SetNativeControl (entry);
|
SetNativeControl (entry);
|
||||||
}
|
}
|
||||||
|
@ -100,8 +100,8 @@ namespace Ooui.Forms.Renderers
|
||||||
|
|
||||||
if (disposing) {
|
if (disposing) {
|
||||||
if (Control != null) {
|
if (Control != null) {
|
||||||
Control.Inputted -= OnStarted;
|
//Control.Input -= OnStarted;
|
||||||
Control.Changed -= OnEnded;
|
Control.Change -= OnEnded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ namespace Ooui.Forms.Renderers
|
||||||
|
|
||||||
if (disposing) {
|
if (disposing) {
|
||||||
if (Control != null) {
|
if (Control != null) {
|
||||||
Control.Inputted -= HandleChanged;
|
Control.Input -= HandleChanged;
|
||||||
//Control.Started -= OnStarted;
|
//Control.Started -= OnStarted;
|
||||||
Control.Changed -= OnEnded;
|
Control.Change -= OnEnded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,9 +46,9 @@ namespace Ooui.Forms.Renderers
|
||||||
ClassName = "form-control"
|
ClassName = "form-control"
|
||||||
});
|
});
|
||||||
|
|
||||||
Control.Inputted += HandleChanged;
|
Control.Input += HandleChanged;
|
||||||
//Control.Started += OnStarted;
|
//Control.Started += OnStarted;
|
||||||
Control.Changed += OnEnded;
|
Control.Change += OnEnded;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateText ();
|
UpdateText ();
|
||||||
|
|
|
@ -6,7 +6,7 @@ using Xamarin.Forms;
|
||||||
|
|
||||||
namespace Ooui.Forms.Renderers
|
namespace Ooui.Forms.Renderers
|
||||||
{
|
{
|
||||||
public class EntryRenderer : ViewRenderer<Entry, Ooui.Input>
|
public class EntryRenderer : ViewRenderer<Entry, Ooui.TextInput>
|
||||||
{
|
{
|
||||||
Ooui.Color _defaultTextColor;
|
Ooui.Color _defaultTextColor;
|
||||||
bool _disposed;
|
bool _disposed;
|
||||||
|
@ -32,8 +32,8 @@ namespace Ooui.Forms.Renderers
|
||||||
if (disposing) {
|
if (disposing) {
|
||||||
if (Control != null) {
|
if (Control != null) {
|
||||||
//Control.Inputted -= OnEditingBegan;
|
//Control.Inputted -= OnEditingBegan;
|
||||||
Control.Inputted -= OnEditingChanged;
|
Control.Input -= OnEditingChanged;
|
||||||
Control.Changed -= OnEditingEnded;
|
Control.Change -= OnEditingEnded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ namespace Ooui.Forms.Renderers
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Control == null) {
|
if (Control == null) {
|
||||||
var textField = new Ooui.Input (InputType.Text);
|
var textField = new Ooui.TextInput ();
|
||||||
SetNativeControl (textField);
|
SetNativeControl (textField);
|
||||||
|
|
||||||
Debug.Assert (Control != null, "Control != null");
|
Debug.Assert (Control != null, "Control != null");
|
||||||
|
@ -57,10 +57,10 @@ namespace Ooui.Forms.Renderers
|
||||||
|
|
||||||
_defaultTextColor = Colors.Black;
|
_defaultTextColor = Colors.Black;
|
||||||
|
|
||||||
textField.Inputted += OnEditingChanged;
|
textField.Input += OnEditingChanged;
|
||||||
|
|
||||||
//textField.EditingDidBegin += OnEditingBegan;
|
//textField.EditingDidBegin += OnEditingBegan;
|
||||||
textField.Changed += OnEditingEnded;
|
textField.Change += OnEditingEnded;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdatePlaceholder ();
|
UpdatePlaceholder ();
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Ooui.Forms.Renderers
|
||||||
protected override void Dispose (bool disposing)
|
protected override void Dispose (bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
Control.Changed -= OnControlValueChanged;
|
Control.Change -= OnControlValueChanged;
|
||||||
|
|
||||||
base.Dispose (disposing);
|
base.Dispose (disposing);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ namespace Ooui.Forms.Renderers
|
||||||
input.SetAttribute ("data-toggle", "toggle");
|
input.SetAttribute ("data-toggle", "toggle");
|
||||||
SetNativeControl (input);
|
SetNativeControl (input);
|
||||||
input.Call ("$.bootstrapToggle");
|
input.Call ("$.bootstrapToggle");
|
||||||
Control.Changed += OnControlValueChanged;
|
Control.Change += OnControlValueChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
Control.IsChecked = Element.IsToggled;
|
Control.IsChecked = Element.IsToggled;
|
||||||
|
|
|
@ -25,12 +25,12 @@ namespace Ooui
|
||||||
set => SetProperty (ref hidden, value, "hidden");
|
set => SetProperty (ref hidden, value, "hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
public event TargetEventHandler Clicked {
|
public event TargetEventHandler Click {
|
||||||
add => AddEventListener ("click", value);
|
add => AddEventListener ("click", value);
|
||||||
remove => RemoveEventListener ("click", value);
|
remove => RemoveEventListener ("click", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event TargetEventHandler DoubleClicked {
|
public event TargetEventHandler DoubleClick {
|
||||||
add => AddEventListener ("dblclick", value);
|
add => AddEventListener ("dblclick", value);
|
||||||
remove => RemoveEventListener ("dblclick", value);
|
remove => RemoveEventListener ("dblclick", value);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ namespace Ooui
|
||||||
remove => RemoveEventListener ("keydown", value);
|
remove => RemoveEventListener ("keydown", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event TargetEventHandler KeyPressed {
|
public event TargetEventHandler KeyPress {
|
||||||
add => AddEventListener ("keypress", value);
|
add => AddEventListener ("keypress", value);
|
||||||
remove => RemoveEventListener ("keypress", value);
|
remove => RemoveEventListener ("keypress", value);
|
||||||
}
|
}
|
||||||
|
@ -55,17 +55,17 @@ namespace Ooui
|
||||||
remove => RemoveEventListener ("mousedown", value);
|
remove => RemoveEventListener ("mousedown", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event TargetEventHandler MouseEntered {
|
public event TargetEventHandler MouseEnter {
|
||||||
add => AddEventListener ("mouseenter", value);
|
add => AddEventListener ("mouseenter", value);
|
||||||
remove => RemoveEventListener ("mouseenter", value);
|
remove => RemoveEventListener ("mouseenter", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event TargetEventHandler MouseLeft {
|
public event TargetEventHandler MouseLeave {
|
||||||
add => AddEventListener ("mouseleave", value);
|
add => AddEventListener ("mouseleave", value);
|
||||||
remove => RemoveEventListener ("mouseleave", value);
|
remove => RemoveEventListener ("mouseleave", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event TargetEventHandler MouseMoved {
|
public event TargetEventHandler MouseMove {
|
||||||
add => AddEventListener ("mousemove", value);
|
add => AddEventListener ("mousemove", value);
|
||||||
remove => RemoveEventListener ("mousemove", value);
|
remove => RemoveEventListener ("mousemove", value);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ namespace Ooui
|
||||||
remove => RemoveEventListener ("mouseup", value);
|
remove => RemoveEventListener ("mouseup", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event TargetEventHandler Wheeled {
|
public event TargetEventHandler Wheel {
|
||||||
add => AddEventListener ("wheel", value);
|
add => AddEventListener ("wheel", value);
|
||||||
remove => RemoveEventListener ("wheel", value);
|
remove => RemoveEventListener ("wheel", value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace Ooui
|
||||||
set => SetProperty (ref enctype, value ?? "", "enctype");
|
set => SetProperty (ref enctype, value ?? "", "enctype");
|
||||||
}
|
}
|
||||||
|
|
||||||
public event TargetEventHandler Submitted {
|
public event TargetEventHandler Submit {
|
||||||
add => AddEventListener ("submit", value);
|
add => AddEventListener ("submit", value);
|
||||||
remove => RemoveEventListener ("submit", value);
|
remove => RemoveEventListener ("submit", value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,16 +30,11 @@ namespace Ooui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public event TargetEventHandler Changed {
|
public event TargetEventHandler Change {
|
||||||
add => AddEventListener ("change", value);
|
add => AddEventListener ("change", value);
|
||||||
remove => RemoveEventListener ("change", value);
|
remove => RemoveEventListener ("change", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event TargetEventHandler Inputted {
|
|
||||||
add => AddEventListener ("input", value);
|
|
||||||
remove => RemoveEventListener ("input", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
string placeholder = "";
|
string placeholder = "";
|
||||||
public string Placeholder {
|
public string Placeholder {
|
||||||
get => placeholder;
|
get => placeholder;
|
||||||
|
@ -77,7 +72,7 @@ namespace Ooui
|
||||||
: base ("input")
|
: base ("input")
|
||||||
{
|
{
|
||||||
// Subscribe to the change event so we always get up-to-date values
|
// Subscribe to the change event so we always get up-to-date values
|
||||||
Changed += (s, e) => {};
|
Change += (s, e) => {};
|
||||||
}
|
}
|
||||||
|
|
||||||
public Input (InputType type)
|
public Input (InputType type)
|
||||||
|
|
|
@ -10,12 +10,12 @@ namespace Ooui
|
||||||
set => SetProperty (ref val, value ?? "", "value");
|
set => SetProperty (ref val, value ?? "", "value");
|
||||||
}
|
}
|
||||||
|
|
||||||
public event TargetEventHandler Changed {
|
public event TargetEventHandler Change {
|
||||||
add => AddEventListener ("change", value);
|
add => AddEventListener ("change", value);
|
||||||
remove => RemoveEventListener ("change", value);
|
remove => RemoveEventListener ("change", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event TargetEventHandler Inputted {
|
public event TargetEventHandler Input {
|
||||||
add => AddEventListener ("input", value);
|
add => AddEventListener ("input", value);
|
||||||
remove => RemoveEventListener ("input", value);
|
remove => RemoveEventListener ("input", value);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ namespace Ooui
|
||||||
: base ("select")
|
: base ("select")
|
||||||
{
|
{
|
||||||
// Subscribe to the change event so we always get up-to-date values
|
// 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)
|
public void AddOption (string label, string value)
|
||||||
|
|
|
@ -4,12 +4,12 @@ namespace Ooui
|
||||||
{
|
{
|
||||||
public class TextArea : FormControl
|
public class TextArea : FormControl
|
||||||
{
|
{
|
||||||
public event TargetEventHandler Changed {
|
public event TargetEventHandler Change {
|
||||||
add => AddEventListener ("change", value);
|
add => AddEventListener ("change", value);
|
||||||
remove => RemoveEventListener ("change", value);
|
remove => RemoveEventListener ("change", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event TargetEventHandler Inputted {
|
public event TargetEventHandler Input {
|
||||||
add => AddEventListener ("input", value);
|
add => AddEventListener ("input", value);
|
||||||
remove => RemoveEventListener ("input", value);
|
remove => RemoveEventListener ("input", value);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ namespace Ooui
|
||||||
: base ("textarea")
|
: base ("textarea")
|
||||||
{
|
{
|
||||||
// Subscribe to the change event so we always get up-to-date values
|
// Subscribe to the change event so we always get up-to-date values
|
||||||
Changed += (s, e) => {};
|
Change += (s, e) => {};
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextArea (string text)
|
public TextArea (string text)
|
||||||
|
|
|
@ -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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,7 +21,7 @@ namespace AspNetCoreMvc.Controllers
|
||||||
var head = new Heading { Text = "Click away!" };
|
var head = new Heading { Text = "Click away!" };
|
||||||
var label = new Label { Text = "0" };
|
var label = new Label { Text = "0" };
|
||||||
var btn = new Button { Text = "Increase" };
|
var btn = new Button { Text = "Increase" };
|
||||||
btn.Clicked += (sender, e) => {
|
btn.Click += (sender, e) => {
|
||||||
count++;
|
count++;
|
||||||
label.Text = count.ToString ();
|
label.Text = count.ToString ();
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,7 +49,7 @@ class Program
|
||||||
|
|
||||||
// Add some logic to it
|
// Add some logic to it
|
||||||
var count = 0;
|
var count = 0;
|
||||||
button.Clicked += (s, e) => {
|
button.Click += (s, e) => {
|
||||||
count++;
|
count++;
|
||||||
button.Text = $"Clicked {count} times";
|
button.Text = $"Clicked {count} times";
|
||||||
};
|
};
|
||||||
|
@ -81,7 +81,7 @@ Button MakeButton()
|
||||||
{
|
{
|
||||||
var button = new Button("Click me!");
|
var button = new Button("Click me!");
|
||||||
var count = 0;
|
var count = 0;
|
||||||
button.Clicked += (s, e) => {
|
button.Click += (s, e) => {
|
||||||
count++;
|
count++;
|
||||||
button.Text = $"Clicked {count} times";
|
button.Text = $"Clicked {count} times";
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Samples
|
||||||
};
|
};
|
||||||
button.Style.MarginTop = "2em";
|
button.Style.MarginTop = "2em";
|
||||||
var count = 0;
|
var count = 0;
|
||||||
button.Clicked += (s, e) => {
|
button.Click += (s, e) => {
|
||||||
count++;
|
count++;
|
||||||
button.Text = $"Clicked {count} times";
|
button.Text = $"Clicked {count} times";
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace Samples
|
||||||
};
|
};
|
||||||
var context = canvas.GetContext2D ();
|
var context = canvas.GetContext2D ();
|
||||||
|
|
||||||
canvas.Clicked += (s, e) => {
|
canvas.Click += (s, e) => {
|
||||||
var radius = 10;
|
var radius = 10;
|
||||||
context.BeginPath ();
|
context.BeginPath ();
|
||||||
if (toolSel.Value == "box") {
|
if (toolSel.Value == "box") {
|
||||||
|
@ -47,7 +47,7 @@ namespace Samples
|
||||||
Type = ButtonType.Submit,
|
Type = ButtonType.Submit,
|
||||||
ClassName = "btn btn-danger",
|
ClassName = "btn btn-danger",
|
||||||
};
|
};
|
||||||
clearbtn.Clicked += (s, e) => {
|
clearbtn.Click += (s, e) => {
|
||||||
context.ClearRect (0, 0, canvas.Width, canvas.Height);
|
context.ClearRect (0, 0, canvas.Width, canvas.Height);
|
||||||
};
|
};
|
||||||
clearbtn.Style.Display = "block";
|
clearbtn.Style.Display = "block";
|
||||||
|
|
|
@ -66,19 +66,19 @@ namespace Samples
|
||||||
if (string.IsNullOrWhiteSpace (input.Value))
|
if (string.IsNullOrWhiteSpace (input.Value))
|
||||||
return;
|
return;
|
||||||
var item = new Item (input.Value);
|
var item = new Item (input.Value);
|
||||||
item.Clicked += (s, e) => {
|
item.Click += (s, e) => {
|
||||||
item.IsDone = !item.IsDone;
|
item.IsDone = !item.IsDone;
|
||||||
};
|
};
|
||||||
items.InsertBefore (item, items.FirstChild);
|
items.InsertBefore (item, items.FirstChild);
|
||||||
input.Value = "";
|
input.Value = "";
|
||||||
}
|
}
|
||||||
addbtn.Clicked += (s, e) => {
|
addbtn.Click += (s, e) => {
|
||||||
AddItem ();
|
AddItem ();
|
||||||
};
|
};
|
||||||
inputForm.Submitted += (s, e) => {
|
inputForm.Submit += (s, e) => {
|
||||||
AddItem ();
|
AddItem ();
|
||||||
};
|
};
|
||||||
clearbtn.Clicked += (s, e) => {
|
clearbtn.Click += (s, e) => {
|
||||||
var toremove = new List<Node> ();
|
var toremove = new List<Node> ();
|
||||||
foreach (Item i in items.Children) {
|
foreach (Item i in items.Children) {
|
||||||
if (i.IsDone) toremove.Add (i);
|
if (i.IsDone) toremove.Add (i);
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace Tests
|
||||||
listened = listened || (m.MessageType == MessageType.Listen);
|
listened = listened || (m.MessageType == MessageType.Listen);
|
||||||
};
|
};
|
||||||
Assert.IsFalse (listened);
|
Assert.IsFalse (listened);
|
||||||
b.Clicked += (s, e) => {
|
b.Click += (s, e) => {
|
||||||
clicked = true;
|
clicked = true;
|
||||||
};
|
};
|
||||||
Assert.IsTrue (listened);
|
Assert.IsTrue (listened);
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace Tests
|
||||||
var b = new Button ();
|
var b = new Button ();
|
||||||
p.AppendChild (b);
|
p.AppendChild (b);
|
||||||
var clicked = false;
|
var clicked = false;
|
||||||
b.Clicked += (s, e) => {
|
b.Click += (s, e) => {
|
||||||
clicked = true;
|
clicked = true;
|
||||||
};
|
};
|
||||||
p.Receive (Message.Event (b.Id, "click"));
|
p.Receive (Message.Event (b.Id, "click"));
|
||||||
|
|
Loading…
Reference in New Issue