aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/Button.cs
diff options
context:
space:
mode:
authorjp <jp_bruyere@hotmail.com>2016-04-19 12:32:25 +0200
committerjp <jp_bruyere@hotmail.com>2016-04-19 12:32:25 +0200
commit9fc6231e18e12eaa4269e2fe75071ac469473cf4 (patch)
tree1e01c485d64c27a8b130a1bfcbe2ab837913d218 /src/GraphicObjects/Button.cs
parent8f841bd580d8a1ed3fd341e83dce478d9a9ca6bb (diff)
add some events to Button and IsPressed var
Diffstat (limited to 'src/GraphicObjects/Button.cs')
-rw-r--r--src/GraphicObjects/Button.cs42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/GraphicObjects/Button.cs b/src/GraphicObjects/Button.cs
index 0b37118c..3dd10606 100644
--- a/src/GraphicObjects/Button.cs
+++ b/src/GraphicObjects/Button.cs
@@ -16,15 +16,21 @@ namespace Crow
[DefaultTemplate("#Crow.Templates.Button.crow")]
public class Button : TemplatedContainer
{
+ string caption;
+ string image;
+ bool isPressed;
+ Container _contentContainer;
+
#region CTOR
public Button() : base()
{}
#endregion
- string caption;
- string image;
- Container _contentContainer;
+ public event EventHandler Pressed;
+ public event EventHandler Released;
+ public event EventHandler Clicked;
+ #region TemplatedContainer overrides
public override GraphicObject Content {
get {
return _contentContainer == null ? null : _contentContainer.Child;
@@ -40,6 +46,7 @@ namespace Crow
_contentContainer = this.child.FindByName ("Content") as Container;
}
+ #endregion
#region GraphicObject Overrides
public override void ResolveBindings ()
@@ -50,12 +57,20 @@ namespace Crow
}
public override void onMouseDown (object sender, MouseButtonEventArgs e)
{
+ IsPressed = true;
+
base.onMouseDown (sender, e);
+
+ //TODO:remove
NotifyValueChanged ("State", "pressed");
}
public override void onMouseUp (object sender, MouseButtonEventArgs e)
{
+ IsPressed = false;
+
base.onMouseUp (sender, e);
+
+ //TODO:remove
NotifyValueChanged ("State", "normal");
}
#endregion
@@ -79,6 +94,25 @@ namespace Crow
image = value;
NotifyValueChanged ("Image", image);
}
- }
+ }
+ [XmlAttributeAttribute()][DefaultValue(false)]
+ public bool IsPressed
+ {
+ get { return isPressed; }
+ set
+ {
+ if (isPressed == value)
+ return;
+
+ isPressed = value;
+
+ NotifyValueChanged ("IsPressed", isPressed);
+
+ if (isPressed)
+ Pressed.Raise (this, null);
+ else
+ Released.Raise (this, null);
+ }
+ }
}
}