MacOS: Implement Focused property and FocusChanged event.

This commit is contained in:
kanato 2009-11-15 04:12:37 +00:00
parent 103190ebf4
commit 63b314c4a8

View file

@ -67,6 +67,7 @@ namespace OpenTK.Platform.MacOS
KeyPressEventArgs mKeyPressArgs = new KeyPressEventArgs((char)0); KeyPressEventArgs mKeyPressArgs = new KeyPressEventArgs((char)0);
bool mMouseIn = false; bool mMouseIn = false;
bool mIsActive = false;
#endregion #endregion
@ -202,6 +203,8 @@ namespace OpenTK.Platform.MacOS
new EventTypeSpec(EventClass.Window, WindowEventKind.WindowClose), new EventTypeSpec(EventClass.Window, WindowEventKind.WindowClose),
new EventTypeSpec(EventClass.Window, WindowEventKind.WindowClosed), new EventTypeSpec(EventClass.Window, WindowEventKind.WindowClosed),
new EventTypeSpec(EventClass.Window, WindowEventKind.WindowBoundsChanged), 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.MouseDown),
//new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseUp), //new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseUp),
@ -412,6 +415,14 @@ namespace OpenTK.Platform.MacOS
return OSStatus.EventNotHandled; return OSStatus.EventNotHandled;
case WindowEventKind.WindowActivate:
OnActivate();
return OSStatus.EventNotHandled;
case WindowEventKind.WindowDeactivate:
OnDeactivate();
return OSStatus.EventNotHandled;
default: default:
Debug.Print("{0}", evt); Debug.Print("{0}", evt);
@ -772,7 +783,7 @@ namespace OpenTK.Platform.MacOS
public bool Focused public bool Focused
{ {
get { throw new NotImplementedException(); } get { return this.mIsActive; }
} }
public Rectangle Bounds public Rectangle Bounds
@ -1027,6 +1038,18 @@ namespace OpenTK.Platform.MacOS
MouseEnter(this, EventArgs.Empty); 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 #endregion