Add more events to elements

Fix #2
This commit is contained in:
Frank A. Krueger 2017-06-18 22:28:14 -07:00
parent 6fcbaa347e
commit 35d1ba662b
5 changed files with 76 additions and 6 deletions

View File

@ -13,11 +13,6 @@ namespace Ooui
set => SetProperty (ref typ, value, "type"); set => SetProperty (ref typ, value, "type");
} }
public event EventHandler Clicked {
add => AddEventListener ("click", value);
remove => RemoveEventListener ("click", value);
}
public Button () public Button ()
: base ("button") : base ("button")
{ {

View File

@ -91,7 +91,7 @@ function msgListen (m) {
id: m.id, id: m.id,
k: m.k, k: m.k,
}; };
if (m.k === "change") { if (m.k === "change" || m.k === "input") {
em.v = node.value; em.v = node.value;
} }
const ems = JSON.stringify (em); const ems = JSON.stringify (em);

View File

@ -25,6 +25,71 @@ namespace Ooui
set => SetProperty (ref hidden, value, "hidden"); set => SetProperty (ref hidden, value, "hidden");
} }
public event EventHandler Clicked {
add => AddEventListener ("click", value);
remove => RemoveEventListener ("click", value);
}
public event EventHandler DoubleClicked {
add => AddEventListener ("dblclick", value);
remove => RemoveEventListener ("dblclick", value);
}
public event EventHandler KeyDown {
add => AddEventListener ("keydown", value);
remove => RemoveEventListener ("keydown", value);
}
public event EventHandler KeyPressed {
add => AddEventListener ("keypress", value);
remove => RemoveEventListener ("keypress", value);
}
public event EventHandler KeyUp {
add => AddEventListener ("keyup", value);
remove => RemoveEventListener ("keyup", value);
}
public event EventHandler MouseDown {
add => AddEventListener ("mousedown", value);
remove => RemoveEventListener ("mousedown", value);
}
public event EventHandler MouseEntered {
add => AddEventListener ("mouseenter", value);
remove => RemoveEventListener ("mouseenter", value);
}
public event EventHandler MouseLeft {
add => AddEventListener ("mouseleave", value);
remove => RemoveEventListener ("mouseleave", value);
}
public event EventHandler MouseMove {
add => AddEventListener ("mousemove", value);
remove => RemoveEventListener ("mousemove", value);
}
public event EventHandler MouseOut {
add => AddEventListener ("mouseout", value);
remove => RemoveEventListener ("mouseout", value);
}
public event EventHandler MouseOver {
add => AddEventListener ("mouseover", value);
remove => RemoveEventListener ("mouseover", value);
}
public event EventHandler MouseUp {
add => AddEventListener ("mouseup", value);
remove => RemoveEventListener ("mouseup", value);
}
public event EventHandler Wheeled {
add => AddEventListener ("wheel", value);
remove => RemoveEventListener ("wheel", value);
}
protected Element (string tagName) protected Element (string tagName)
: base (tagName) : base (tagName)
{ {

View File

@ -32,6 +32,11 @@ namespace Ooui
remove => RemoveEventListener ("change", value); remove => RemoveEventListener ("change", value);
} }
public event EventHandler Inputted {
add => AddEventListener ("input", value);
remove => RemoveEventListener ("input", value);
}
bool isChecked = false; bool isChecked = false;
public bool IsChecked { public bool IsChecked {
get => isChecked; get => isChecked;

View File

@ -9,6 +9,11 @@ namespace Ooui
remove => RemoveEventListener ("change", value); remove => RemoveEventListener ("change", value);
} }
public event EventHandler Inputted {
add => AddEventListener ("input", value);
remove => RemoveEventListener ("input", value);
}
string val = ""; string val = "";
public string Value { public string Value {
get => val; get => val;