mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-11 08:35:39 +00:00
Added KeyDown and KeyUp events.
This commit is contained in:
parent
3726c9b94f
commit
6e8d120d4f
|
@ -229,10 +229,20 @@ namespace OpenTK
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event EventHandler<EventArgs> WindowStateChanged;
|
event EventHandler<EventArgs> WindowStateChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs whenever a keybord key is pressed.
|
||||||
|
/// </summary>
|
||||||
|
event EventHandler<OpenTK.Input.KeyboardKeyEventArgs> KeyDown;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs whenever a character is typed.
|
/// Occurs whenever a character is typed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event EventHandler<KeyPressEventArgs> KeyPress;
|
event EventHandler<KeyPressEventArgs> KeyPress;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs whenever a keyboard key is released.
|
||||||
|
/// </summary>
|
||||||
|
event EventHandler<OpenTK.Input.KeyboardKeyEventArgs> KeyUp;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs whenever the mouse cursor leaves the window <see cref="Bounds"/>.
|
/// Occurs whenever the mouse cursor leaves the window <see cref="Bounds"/>.
|
||||||
|
@ -251,9 +261,6 @@ namespace OpenTK
|
||||||
//event EventHandler<MouseEventArgs> MouseClick;
|
//event EventHandler<MouseEventArgs> MouseClick;
|
||||||
//event EventHandler<MouseEventArgs> MouseDoubleClick;
|
//event EventHandler<MouseEventArgs> MouseDoubleClick;
|
||||||
|
|
||||||
//event EventHandler<KeyEventArgs> KeyDown;
|
|
||||||
//event EventHandler<KeyEventArgs> KeyUp;
|
|
||||||
|
|
||||||
//event EventHandler<DragEventArgs> DragDrop;
|
//event EventHandler<DragEventArgs> DragDrop;
|
||||||
//event EventHandler<DragEventArgs> DragEnter;
|
//event EventHandler<DragEventArgs> DragEnter;
|
||||||
//event EventHandler<DragEventArgs> DragOver;
|
//event EventHandler<DragEventArgs> DragOver;
|
||||||
|
|
|
@ -50,6 +50,7 @@ namespace OpenTK
|
||||||
|
|
||||||
private bool disposed, events;
|
private bool disposed, events;
|
||||||
private bool cursor_visible = true;
|
private bool cursor_visible = true;
|
||||||
|
private bool previous_cursor_visible = true;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -588,11 +589,21 @@ namespace OpenTK
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<EventArgs> IconChanged = delegate { };
|
public event EventHandler<EventArgs> IconChanged = delegate { };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs whenever a keybord key is pressed.
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler<OpenTK.Input.KeyboardKeyEventArgs> KeyDown = delegate { };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs whenever a character is typed.
|
/// Occurs whenever a character is typed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<KeyPressEventArgs> KeyPress = delegate { };
|
public event EventHandler<KeyPressEventArgs> KeyPress = delegate { };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs whenever a keyboard key is released.
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler<OpenTK.Input.KeyboardKeyEventArgs> KeyUp = delegate { };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs whenever the window is moved.
|
/// Occurs whenever the window is moved.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -746,6 +757,20 @@ namespace OpenTK
|
||||||
/// <param name="e">Not used.</param>
|
/// <param name="e">Not used.</param>
|
||||||
protected virtual void OnFocusedChanged(EventArgs e)
|
protected virtual void OnFocusedChanged(EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (!Focused)
|
||||||
|
{
|
||||||
|
// Release cursor when losing focus, to ensure
|
||||||
|
// IDEs continue working as expected.
|
||||||
|
previous_cursor_visible = CursorVisible;
|
||||||
|
CursorVisible = true;
|
||||||
|
}
|
||||||
|
else if (!previous_cursor_visible)
|
||||||
|
{
|
||||||
|
// Make cursor invisible when focus is regained
|
||||||
|
// if cursor was invisible on previous focus loss.
|
||||||
|
previous_cursor_visible = true;
|
||||||
|
CursorVisible = false;
|
||||||
|
}
|
||||||
FocusedChanged(this, e);
|
FocusedChanged(this, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -764,6 +789,18 @@ namespace OpenTK
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region OnKeyDown
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs whenever a keybord key is pressed.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void OnKeyDown(KeyboardKeyEventArgs e)
|
||||||
|
{
|
||||||
|
KeyDown(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region OnKeyPress
|
#region OnKeyPress
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -777,6 +814,19 @@ namespace OpenTK
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region OnKeyUp
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when a keybord key is released.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">The <see cref="OpenTK.KeyboardKeyEventArgs"/> for this event.</param>
|
||||||
|
protected virtual void OnKeyUp(KeyboardKeyEventArgs e)
|
||||||
|
{
|
||||||
|
KeyUp(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region OnMove
|
#region OnMove
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue