aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2015-10-19 16:49:05 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2015-10-19 16:49:05 +0200
commit5223bf7dc4f5f085d4bfde7c079a45adf5f344e7 (patch)
tree701566767b7a913e75f94d07709a8a4a7b1b0174 /src
parentd57ae20644694ed4862785be98d3ead18100315f (diff)
Debug
* Spinner.cs: updated with binding system * OpenTKGameWindow.cs: ensure focused, active and hover widget were not removed from the graphic tree, fire MouseButtonUp special event only if threre's no actived widget * testSpinner.goml: updated to test focus
Diffstat (limited to 'src')
-rw-r--r--src/GraphicObjects/Spinner.cs3
-rwxr-xr-xsrc/OpenTKGameWindow.cs85
2 files changed, 49 insertions, 39 deletions
diff --git a/src/GraphicObjects/Spinner.cs b/src/GraphicObjects/Spinner.cs
index ea992b18..5336a0bb 100644
--- a/src/GraphicObjects/Spinner.cs
+++ b/src/GraphicObjects/Spinner.cs
@@ -42,7 +42,6 @@ namespace go
protected override void loadTemplate (GraphicObject template = null)
{
base.loadTemplate (template);
- labCpt = this.child.FindByName ("labCpt") as Label;
}
#endregion
@@ -54,7 +53,6 @@ namespace go
// return;
Value += this.SmallIncrement;
- labCpt.Text = Value.ToString ();
}
void onDown (object sender, MouseButtonEventArgs e)
{
@@ -63,7 +61,6 @@ namespace go
// return;
Value -= this.SmallIncrement;
- labCpt.Text = Value.ToString ();
}
}
diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs
index 6b16f157..7cc84bca 100755
--- a/src/OpenTKGameWindow.cs
+++ b/src/OpenTKGameWindow.cs
@@ -142,7 +142,8 @@ namespace go
if (_focusedWidget != null)
_focusedWidget.onUnfocused (this, null);
_focusedWidget = value;
- _focusedWidget.onFocused (this, null);
+ if (_focusedWidget != null)
+ _focusedWidget.onFocused (this, null);
}
}
#endregion
@@ -437,46 +438,57 @@ namespace go
void Mouse_Move(object sender, MouseMoveEventArgs e)
{
if (_activeWidget != null) {
- //send move evt even if mouse move outside bounds
- _activeWidget.onMouseMove (_activeWidget, e);
- return;
+ //first, ensure object is still in the graphic tree
+ if (_activeWidget.TopContainer == null) {
+ activeWidget = null;
+ } else {
+
+ //send move evt even if mouse move outside bounds
+ _activeWidget.onMouseMove (_activeWidget, e);
+ return;
+ }
}
if (_hoverWidget != null) {
- //check topmost graphicobject first
- GraphicObject tmp = _hoverWidget;
- GraphicObject topc = null;
- while (tmp is GraphicObject) {
- topc = tmp;
- tmp = tmp.Parent as GraphicObject;
- }
- int idxhw = GraphicObjects.IndexOf (topc);
- if (idxhw != 0) {
- int i = 0;
- while (i < idxhw) {
- if (GraphicObjects [i].MouseIsIn (e.Position)) {
- _hoverWidget.onMouseLeave (this, e);
- GraphicObjects [i].checkHoverWidget (e);
- return;
+ //first, ensure object is still in the graphic tree
+ if (_hoverWidget.TopContainer == null) {
+ hoverWidget = null;
+ } else {
+ //check topmost graphicobject first
+ GraphicObject tmp = _hoverWidget;
+ GraphicObject topc = null;
+ while (tmp is GraphicObject) {
+ topc = tmp;
+ tmp = tmp.Parent as GraphicObject;
+ }
+ int idxhw = GraphicObjects.IndexOf (topc);
+ if (idxhw != 0) {
+ int i = 0;
+ while (i < idxhw) {
+ if (GraphicObjects [i].MouseIsIn (e.Position)) {
+ _hoverWidget.onMouseLeave (this, e);
+ GraphicObjects [i].checkHoverWidget (e);
+ return;
+ }
+ i++;
}
- i++;
}
- }
- if (_hoverWidget.MouseIsIn (e.Position)) {
- _hoverWidget.checkHoverWidget (e);
- return;
- } else {
- _hoverWidget.onMouseLeave (this, e);
- //seek upward from last focused graph obj's
- while (_hoverWidget.Parent as GraphicObject!=null) {
- _hoverWidget = _hoverWidget.Parent as GraphicObject;
- if (_hoverWidget.MouseIsIn (e.Position)) {
- _hoverWidget.checkHoverWidget (e);
- return;
- } else
- _hoverWidget.onMouseLeave (this, e);
+ if (_hoverWidget.MouseIsIn (e.Position)) {
+ _hoverWidget.checkHoverWidget (e);
+ return;
+ } else {
+ _hoverWidget.onMouseLeave (this, e);
+ //seek upward from last focused graph obj's
+ while (_hoverWidget.Parent as GraphicObject != null) {
+ _hoverWidget = _hoverWidget.Parent as GraphicObject;
+ if (_hoverWidget.MouseIsIn (e.Position)) {
+ _hoverWidget.checkHoverWidget (e);
+ return;
+ } else
+ _hoverWidget.onMouseLeave (this, e);
+ }
}
}
}
@@ -495,12 +507,13 @@ namespace go
}
void Mouse_ButtonUp(object sender, MouseButtonEventArgs e)
{
- if (_activeWidget == null)
+ if (_activeWidget == null) {
+ MouseButtonUp.Raise (this, e);
return;
+ }
_activeWidget.onMouseButtonUp (this, e);
_activeWidget = null;
- MouseButtonUp.Raise (this, e);
}
void Mouse_ButtonDown(object sender, MouseButtonEventArgs e)
{