aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2015-09-07 09:08:12 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2015-09-07 09:08:12 +0200
commit167e50bf7c4af84a6793326e39b0d3e41d4eb8bf (patch)
tree57a9239773e3eb0b60e648119ddb782db92439f3
parentbacf29e47409c20292b6861e6ef40bfc2119eb7b (diff)
Focus improvments:
New function (checkHoverWidget) to check most inner control under the mouse, than bubble onMouseMove through the parents
-rw-r--r--MonoDevelop.GOLib/src/GOLibGtkHost.cs9
-rw-r--r--Tests/GOLIBTest_4.cs6
-rwxr-xr-xTests/Interfaces/test4.goml5
-rwxr-xr-xTests/Interfaces/testWindow.goml3
-rw-r--r--src/GraphicObjects/GraphicObject.cs23
-rw-r--r--src/GraphicObjects/Group.cs16
-rw-r--r--src/GraphicObjects/PrivateContainer.cs8
-rw-r--r--src/GraphicObjects/Scroller.cs4
-rwxr-xr-xsrc/OpenTKGameWindow.cs8
9 files changed, 45 insertions, 37 deletions
diff --git a/MonoDevelop.GOLib/src/GOLibGtkHost.cs b/MonoDevelop.GOLib/src/GOLibGtkHost.cs
index 03c96220..c8dcecda 100644
--- a/MonoDevelop.GOLib/src/GOLibGtkHost.cs
+++ b/MonoDevelop.GOLib/src/GOLibGtkHost.cs
@@ -309,13 +309,13 @@ namespace MonoDevelop.GOLib
{
if (_activeWidget != null) {
//send move evt even if mouse move outside bounds
- _activeWidget.onMouseMove (this, e);
+ _activeWidget.checkHoverWidget (e);
return;
}
if (_hoverWidget != null) {
if (_hoverWidget.MouseIsIn (e.Position)) {
- _hoverWidget.onMouseMove (this, e);
+ _hoverWidget.checkHoverWidget (e);
return;
} else {
_hoverWidget.onMouseLeave (this, e);
@@ -323,7 +323,7 @@ namespace MonoDevelop.GOLib
while (_hoverWidget.Parent as GraphicObject!=null) {
_hoverWidget = _hoverWidget.Parent as GraphicObject;
if (_hoverWidget.MouseIsIn (e.Position)) {
- _hoverWidget.onMouseMove (this, e);
+ _hoverWidget.checkHoverWidget (e);
return;
} else
_hoverWidget.onMouseLeave (this, e);
@@ -335,12 +335,13 @@ namespace MonoDevelop.GOLib
for (int i = 0; i < GraphicObjects.Count; i++) {
GraphicObject g = GraphicObjects[i];
if (g.MouseIsIn (e.Position)) {
- g.onMouseMove (this, e);
+ g.checkHoverWidget (e);
PutOnTop (g);
return;
}
}
_hoverWidget = null;
+ MouseMove.Raise (this, e);
}
void Mouse_ButtonUp(object sender, MouseButtonEventArgs e)
{
diff --git a/Tests/GOLIBTest_4.cs b/Tests/GOLIBTest_4.cs
index 24cffc98..8b1c7cd2 100644
--- a/Tests/GOLIBTest_4.cs
+++ b/Tests/GOLIBTest_4.cs
@@ -13,6 +13,7 @@ using System.Diagnostics;
using go;
using System.Threading;
using System.Collections.Generic;
+using System.IO;
namespace test
@@ -82,6 +83,9 @@ namespace test
{
base.OnLoad (e);
+ this.Cursor = XCursor.NE;
+
+
LoadInterface("Interfaces/test4.goml", out c);
//LoadInterface("golibtests/test4.xml", out c2);
//c2.HorizontalAlignment = HorizontalAlignment.Left;
@@ -142,7 +146,7 @@ namespace test
}
void pFps_mousemove(object sender, MouseMoveEventArgs e)
{
- if (!e.Mouse.IsButtonDown (MouseButton.Left))
+ if (!e.Mouse.IsButtonDown (MouseButton.Left)||sender!=c)
return;
redrawClip.AddRectangle (c.ScreenCoordinates(c.Slot));
c.Left += e.XDelta;
diff --git a/Tests/Interfaces/test4.goml b/Tests/Interfaces/test4.goml
index 0cdc2545..02dadec8 100755
--- a/Tests/Interfaces/test4.goml
+++ b/Tests/Interfaces/test4.goml
@@ -1,9 +1,10 @@
<?xml version="1.0"?>
-<Group Name="MainGrp"
+<Group Name="MainGrp" Focusable="true"
Width="800" Height="500"
Background="0,5;0,5;0,5;0,5" Foreground="White"
Margin="10" >
<Border Margin="10"
+ Name="mainBorder"
BorderWidth="2" BorderColor="Transparent"
Focusable="True"
MouseEnter="{BorderColor = White}"
@@ -18,7 +19,7 @@
<Label Name="labMouse" Text="MousePos"/>
<HorizontalStack WidgetSpacing="10">
<VerticalStack Width="100">
- <Checkbox Name="chk1"/>
+ <Checkbox Name="chk1" Focusable="true"/>
<Checkbox Name="chk2" IsChecked="true"/>
<Checkbox Name="chk3" Template="#go.Templates.Checkbox2.goml"/>
<Checkbox Name="chk4">
diff --git a/Tests/Interfaces/testWindow.goml b/Tests/Interfaces/testWindow.goml
index 68759d9e..32c64401 100755
--- a/Tests/Interfaces/testWindow.goml
+++ b/Tests/Interfaces/testWindow.goml
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<!--<Group>-->
-<Window Name="window1" Left="10" Top="10" Title="Test window" Width="200" Height="200" Background="0,5;0,5;0,5;0,5" >
+<Window Name="window1" Left="10" Top="10" Title="Test window" Width="200" Height="200" Background="0,5;0,5;0,5;0,5"
+ Focusable="True">
<VerticalStack Height="0" Width="0">
<Label Text="{fps}" Background="DarkRed"/>
<Label Text="{fpsMin}" />
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index e1972669..d74442d7 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -661,20 +661,23 @@ namespace go
{
return Visible ? ScreenCoordinates(Slot).ContainsOrIsEqual (m) : false;
}
- internal virtual void checkHoverWidget(Point m)
+ internal virtual void checkHoverWidget(MouseMoveEventArgs e)
{
-
- }
- public virtual void onMouseMove(object sender, MouseMoveEventArgs e)
- {
- //ILayoutable w = sender as ILayoutable;
-
if (TopContainer.hoverWidget != this) {
TopContainer.hoverWidget = this;
- onMouseEnter (sender, e);
+ onMouseEnter (this, e);
}
-
- MouseMove.Raise (this, e);
+
+ this.onMouseMove (this, e);
+ }
+ public virtual void onMouseMove(object sender, MouseMoveEventArgs e)
+ {
+ //bubble event to the top
+ GraphicObject p = Parent as GraphicObject;
+ if (p != null)
+ p.onMouseMove(sender,e);
+
+ MouseMove.Raise (sender, e);
}
public virtual void onMouseButtonUp(object sender, MouseButtonEventArgs e){
if (MouseIsIn (e.Position))
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs
index e2d64c89..41294231 100644
--- a/src/GraphicObjects/Group.cs
+++ b/src/GraphicObjects/Group.cs
@@ -215,17 +215,17 @@ namespace go
#region Mouse handling
- public override void onMouseMove (object sender, OpenTK.Input.MouseMoveEventArgs e)
+ internal override void checkHoverWidget (OpenTK.Input.MouseMoveEventArgs e)
{
foreach (GraphicObject g in Children)
- {
+ {
if (g.MouseIsIn(e.Position))
- {
- g.onMouseMove (sender, e);
- return;
- }
- }
- base.onMouseMove (sender, e);
+ {
+ g.checkHoverWidget (e);
+ return;
+ }
+ }
+ base.checkHoverWidget (e);
}
#endregion
diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs
index f863fae8..01502bd4 100644
--- a/src/GraphicObjects/PrivateContainer.cs
+++ b/src/GraphicObjects/PrivateContainer.cs
@@ -146,14 +146,12 @@ namespace go
#endregion
#region Mouse handling
- public override void onMouseMove (object sender, MouseMoveEventArgs e)
+ internal override void checkHoverWidget (MouseMoveEventArgs e)
{
- base.onMouseMove (sender, e);
-
+ base.checkHoverWidget (e);
if (child != null)
if (child.MouseIsIn (e.Position))
- child.onMouseMove (sender, e);
-
+ child.checkHoverWidget (e);
}
#endregion
}
diff --git a/src/GraphicObjects/Scroller.cs b/src/GraphicObjects/Scroller.cs
index a413da94..8996c464 100644
--- a/src/GraphicObjects/Scroller.cs
+++ b/src/GraphicObjects/Scroller.cs
@@ -118,10 +118,10 @@ namespace go
{
return Visible ? base.ScreenCoordinates(Slot).ContainsOrIsEqual (m) : false;
}
- public override void onMouseMove (object sender, MouseMoveEventArgs e)
+ internal override void checkHoverWidget (MouseMoveEventArgs e)
{
Point m = e.Position - new Point ((int)ScrollX, (int)ScrollY);
- base.onMouseMove (sender, new MouseMoveEventArgs(m.X,m.Y,e.XDelta,e.YDelta));
+ base.checkHoverWidget (new MouseMoveEventArgs(m.X,m.Y,e.XDelta,e.YDelta));
}
public override void onMouseWheel (object sender, MouseWheelEventArgs e)
{
diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs
index d7cecd4e..59e02cf1 100755
--- a/src/OpenTKGameWindow.cs
+++ b/src/OpenTKGameWindow.cs
@@ -385,13 +385,13 @@ namespace go
{
if (_activeWidget != null) {
//send move evt even if mouse move outside bounds
- _activeWidget.onMouseMove (this, e);
+ _activeWidget.onMouseMove (_activeWidget, e);
return;
}
if (_hoverWidget != null) {
if (_hoverWidget.MouseIsIn (e.Position)) {
- _hoverWidget.onMouseMove (this, e);
+ _hoverWidget.checkHoverWidget (e);
return;
} else {
_hoverWidget.onMouseLeave (this, e);
@@ -399,7 +399,7 @@ namespace go
while (_hoverWidget.Parent as GraphicObject!=null) {
_hoverWidget = _hoverWidget.Parent as GraphicObject;
if (_hoverWidget.MouseIsIn (e.Position)) {
- _hoverWidget.onMouseMove (this, e);
+ _hoverWidget.checkHoverWidget (e);
return;
} else
_hoverWidget.onMouseLeave (this, e);
@@ -411,7 +411,7 @@ namespace go
for (int i = 0; i < GraphicObjects.Count; i++) {
GraphicObject g = GraphicObjects[i];
if (g.MouseIsIn (e.Position)) {
- g.onMouseMove (this, e);
+ g.checkHoverWidget (e);
PutOnTop (g);
return;
}