From c33c997947d4b6442992fa305d3dc9ea526bc9a6 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Thu, 11 Apr 2013 12:20:28 -0400 Subject: [PATCH] TextEdit and TextInput events --- src/SDL2.cs | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/SDL2.cs b/src/SDL2.cs index 8775201..b682b05 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -2147,6 +2147,10 @@ namespace SDL2 public const byte SDL_PRESSED = 0; public const byte SDL_RELEASED = 1; + /* Default size is according to SDL2 default. */ + public const int SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32; + public const int SDL_TEXTINPUTEVENT_TEXT_SIZE = 32; + /* The types of events that can be delivered. */ public enum SDL_EventType : uint { @@ -2251,7 +2255,25 @@ namespace SDL2 public SDL_Keysym keysym; } - //TODO: SDL_Text*Event (need to work out char[] in C#) + [StructLayout(LayoutKind.Sequential)] + public unsafe struct SDL_TextEditingEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public UInt32 windowID; + public fixed char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; + public Int32 start; + public Int32 length; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct SDL_TextInputEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public UInt32 windowID; + public fixed char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; + } /* Mouse motion event structure (event.motion.*) */ [StructLayout(LayoutKind.Sequential)] @@ -2456,7 +2478,10 @@ namespace SDL2 public SDL_WindowEvent window; [FieldOffset(0)] public SDL_KeyboardEvent key; - //TODO: TextEditingEvent, TextInputEvent + [FieldOffset(0)] + public TextEditingEvent edit; + [FieldOffset(0)] + public TextInputEvent text; [FieldOffset(0)] public SDL_MouseMotionEvent motion; [FieldOffset(0)]