Trigger Change event when changing the checked state

This commit is contained in:
Frank A. Krueger 2018-02-02 21:03:42 -08:00
parent d58625129b
commit 589e848f44
No known key found for this signature in database
GPG Key ID: 0471C67474FFE664
2 changed files with 23 additions and 1 deletions

View File

@ -182,6 +182,24 @@ namespace Ooui
return true; return true;
} }
protected virtual bool TriggerEvent (string name)
{
List<TargetEventHandler> handlers = null;
lock (eventListeners) {
List<TargetEventHandler> hs;
if (eventListeners.TryGetValue (name, out hs)) {
handlers = new List<TargetEventHandler> (hs);
}
}
if (handlers != null) {
var args = new TargetEventArgs ();
foreach (var h in handlers) {
h.Invoke (this, args);
}
}
return true;
}
protected virtual bool TriggerEventFromMessage (Message message) protected virtual bool TriggerEventFromMessage (Message message)
{ {
if (message.TargetId != Id) if (message.TargetId != Id)

View File

@ -40,7 +40,11 @@ namespace Ooui
public bool IsChecked { public bool IsChecked {
get => GetBooleanAttribute ("checked"); get => GetBooleanAttribute ("checked");
set => SetBooleanAttributeProperty ("checked", value); set {
if (SetBooleanAttributeProperty ("checked", value)) {
TriggerEvent ("change");
}
}
} }
public double Minimum { public double Minimum {