From 0c0acfbf7588ce0c68e0eca40b17b7b2ab680ff1 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Tue, 27 Oct 2009 23:58:29 +0000 Subject: [PATCH] Track mouse enter/leave events. --- Source/Examples/OpenTK/Test/GameWindowStates.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Examples/OpenTK/Test/GameWindowStates.cs b/Source/Examples/OpenTK/Test/GameWindowStates.cs index 3dd61495..8ca981ee 100644 --- a/Source/Examples/OpenTK/Test/GameWindowStates.cs +++ b/Source/Examples/OpenTK/Test/GameWindowStates.cs @@ -23,6 +23,7 @@ namespace Examples.Tests readonly Font TextFont = new Font(FontFamily.GenericSansSerif, 16); readonly Bitmap TextBitmap = new Bitmap(1024, 256); int texture; + bool mouse_in_window = false; public GameWindowStates() : base(800, 600) @@ -33,6 +34,8 @@ namespace Examples.Tests WindowBorderChanged += delegate(object sender, EventArgs e) { UpdateText(); }; WindowStateChanged += delegate(object sender, EventArgs e) { UpdateText(); }; FocusedChanged += delegate(object sender, EventArgs e) { UpdateText(); }; + MouseEnter += delegate(object sender, EventArgs e) { mouse_in_window = true; UpdateText(); }; + MouseLeave += delegate(object sender, EventArgs e) { mouse_in_window = false; UpdateText(); }; } void KeyUpHandler(object sender, KeyboardKeyEventArgs e) @@ -62,6 +65,7 @@ namespace Examples.Tests gfx.DrawString(String.Format("[1 - 4]: change WindowState (current: {0}).", this.WindowState), TextFont, Brushes.White, new PointF(0, 0)); gfx.DrawString(String.Format("[5 - 7]: change WindowBorder (current: {0}).", this.WindowBorder), TextFont, Brushes.White, new PointF(0, TextFont.Height)); gfx.DrawString(String.Format("Focused: {0}.", this.Focused), TextFont, Brushes.White, new PointF(0, 2 * TextFont.Height)); + gfx.DrawString(String.Format("Mouse {0} window.", mouse_in_window ? "inside" : "outside of"), TextFont, Brushes.White, new PointF(0, 3 * TextFont.Height)); } System.Drawing.Imaging.BitmapData data = TextBitmap.LockBits(new Rectangle(0, 0, TextBitmap.Width, TextBitmap.Height),