From 63b314c4a8567e6a6ef54db7cc289f71c46f1b04 Mon Sep 17 00:00:00 2001 From: kanato Date: Sun, 15 Nov 2009 04:12:37 +0000 Subject: [PATCH] MacOS: Implement Focused property and FocusChanged event. --- .../OpenTK/Platform/MacOS/CarbonGLNative.cs | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs index df1b912d..15c45bf1 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs @@ -67,6 +67,7 @@ namespace OpenTK.Platform.MacOS KeyPressEventArgs mKeyPressArgs = new KeyPressEventArgs((char)0); bool mMouseIn = false; + bool mIsActive = false; #endregion @@ -202,6 +203,8 @@ namespace OpenTK.Platform.MacOS new EventTypeSpec(EventClass.Window, WindowEventKind.WindowClose), new EventTypeSpec(EventClass.Window, WindowEventKind.WindowClosed), new EventTypeSpec(EventClass.Window, WindowEventKind.WindowBoundsChanged), + new EventTypeSpec(EventClass.Window, WindowEventKind.WindowActivate), + new EventTypeSpec(EventClass.Window, WindowEventKind.WindowDeactivate), //new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseDown), //new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseUp), @@ -412,6 +415,14 @@ namespace OpenTK.Platform.MacOS return OSStatus.EventNotHandled; + case WindowEventKind.WindowActivate: + OnActivate(); + return OSStatus.EventNotHandled; + + case WindowEventKind.WindowDeactivate: + OnDeactivate(); + return OSStatus.EventNotHandled; + default: Debug.Print("{0}", evt); @@ -772,7 +783,7 @@ namespace OpenTK.Platform.MacOS public bool Focused { - get { throw new NotImplementedException(); } + get { return this.mIsActive; } } public Rectangle Bounds @@ -1027,6 +1038,18 @@ namespace OpenTK.Platform.MacOS MouseEnter(this, EventArgs.Empty); } + private void OnActivate() + { + mIsActive = true; + if (FocusedChanged != null) + FocusedChanged(this, EventArgs.Empty); + } + private void OnDeactivate() + { + mIsActive = false; + if (FocusedChanged != null) + FocusedChanged(this, EventArgs.Empty); + } #endregion