Class KeyboardComponent
Inherited Members
Namespace: OpenTK.Platform.Native.Windows
Assembly: OpenTK.Platform.dll
Syntax
public class KeyboardComponent : IKeyboardComponent, IPalComponent
Properties
Logger
The logger that this component uses to log diagnostic messages.
Declaration
public ILogger? Logger { get; set; }
Property Value
Type | Description |
---|---|
ILogger |
See Also
Name
Name of the abstraction layer component.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
string |
Provides
Specifies which PAL components this object provides.
Declaration
public PalComponents Provides { get; }
Property Value
Type | Description |
---|---|
PalComponents |
SupportsIme
True if the driver supports input method editor functions.
Declaration
public bool SupportsIme { get; }
Property Value
Type | Description |
---|---|
bool |
SupportsLayouts
True if the driver supports keyboard layout functions.
Declaration
public bool SupportsLayouts { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
BeginIme(WindowHandle)
Invoke input method editor.
Declaration
public void BeginIme(WindowHandle window)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | window | The window corresponding to this IME window. |
EndIme(WindowHandle)
Finish input method editor.
Declaration
public void EndIme(WindowHandle window)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | window | The window corresponding to this IME window. |
GetActiveKeyboardLayout(WindowHandle?)
Get the active keyboard layout.
Declaration
public string GetActiveKeyboardLayout(WindowHandle? handle = null)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | (optional) Handle to a window to query the layout for. Ignored on systems where keyboard layout is global. |
Returns
Type | Description |
---|---|
string | A string which describes the active keyboard layout. |
Exceptions
Type | Condition |
---|---|
PalNotImplementedException | Driver cannot query active keyboard layout. |
GetAvailableKeyboardLayouts()
See list of possible keyboard layouts for this system.
Declaration
public string[] GetAvailableKeyboardLayouts()
Returns
Type | Description |
---|---|
string[] | Array containing possible keyboard layouts. |
Remarks
This function is expensive and should be cached if possible.
GetKeyFromScancode(Scancode)
Gets the Key associated with the specidied Scancode. This function uses the current keyboard layout to determine the mapping.
Declaration
public Key GetKeyFromScancode(Scancode scancode)
Parameters
Type | Name | Description |
---|---|---|
Scancode | scancode | The scancode. |
Returns
Type | Description |
---|---|
Key | The Key associated with the Scancode or Unknown if the scancode can't be mapped to a key. |
See Also
GetKeyboardModifiers()
Gets the current keyboard modifiers.
Declaration
public KeyModifier GetKeyboardModifiers()
Returns
Type | Description |
---|---|
KeyModifier | The current keyboard modifiers. |
See Also
GetKeyboardState(bool[])
Copies the current state of the keyboard into the specified array. This array should be indexed using Scancode values. The length of this array should be an array able to hold all possible Scancode values.
Declaration
public void GetKeyboardState(bool[] keyboardState)
Parameters
Type | Name | Description |
---|---|---|
bool[] | keyboardState | An array to be filled with the keyboard state. |
See Also
GetScancodeFromKey(Key)
Gets the Scancode associated with the specified Key. The Key to Scancode mapping is not 1 to 1, multiple scancodes can produce the same key. This function will return one of the scancodes that produce the key. This function uses the current keyboard layout to determine the mapping.
Declaration
public Scancode GetScancodeFromKey(Key key)
Parameters
Type | Name | Description |
---|---|---|
Key | key | The key. |
Returns
Type | Description |
---|---|
Scancode | The Scancode that produces the Key or Unknown if no scancode produces the key. |
See Also
Initialize(ToolkitOptions)
Initialize the component.
Declaration
public void Initialize(ToolkitOptions options)
Parameters
Type | Name | Description |
---|---|---|
ToolkitOptions | options | The options to initialize the component with. |
See Also
SetImeRectangle(WindowHandle, int, int, int, int)
Set the rectangle to which the IME interface will appear relative to.
Declaration
public void SetImeRectangle(WindowHandle window, int x, int y, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | window | The window corresponding to this IME window. |
int | x | X coordinate of the rectangle in desktop coordinates. |
int | y | Y coordinate of the rectangle in desktop coordinates. |
int | width | Width of the rectangle in desktop units. |
int | height | Height of the rectangle in desktop units. |
Uninitialize()
Uninitialize the component. Frees any native resources used by the component.
Declaration
public void Uninitialize()