Initial support for text input/edit events
This commit is contained in:
@@ -41,6 +41,7 @@ namespace lime {
|
||||
KeyEvent keyEvent;
|
||||
MouseEvent mouseEvent;
|
||||
RenderEvent renderEvent;
|
||||
TextEvent textEvent;
|
||||
TouchEvent touchEvent;
|
||||
UpdateEvent updateEvent;
|
||||
WindowEvent windowEvent;
|
||||
@@ -145,6 +146,12 @@ namespace lime {
|
||||
ProcessMouseEvent (event);
|
||||
break;
|
||||
|
||||
case SDL_TEXTINPUT:
|
||||
case SDL_TEXTEDITING:
|
||||
|
||||
ProcessTextEvent (event);
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT:
|
||||
|
||||
switch (event->window.event) {
|
||||
@@ -337,6 +344,35 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void SDLApplication::ProcessTextEvent (SDL_Event* event) {
|
||||
|
||||
if (TextEvent::callback) {
|
||||
|
||||
switch (event->type) {
|
||||
|
||||
case SDL_TEXTINPUT:
|
||||
|
||||
textEvent.type = TEXT_INPUT;
|
||||
break;
|
||||
|
||||
case SDL_TEXTEDITING:
|
||||
|
||||
textEvent.type = TEXT_EDIT;
|
||||
textEvent.start = event->edit.start;
|
||||
textEvent.length = event->edit.length;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
strcpy (textEvent.text, event->text.text);
|
||||
|
||||
TextEvent::Dispatch (&textEvent);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SDLApplication::ProcessTouchEvent (SDL_Event* event) {
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <ui/GamepadEvent.h>
|
||||
#include <ui/KeyEvent.h>
|
||||
#include <ui/MouseEvent.h>
|
||||
#include <ui/TextEvent.h>
|
||||
#include <ui/TouchEvent.h>
|
||||
#include <ui/WindowEvent.h>
|
||||
#include "SDLWindow.h"
|
||||
@@ -37,6 +38,7 @@ namespace lime {
|
||||
void ProcessGamepadEvent (SDL_Event* event);
|
||||
void ProcessKeyEvent (SDL_Event* event);
|
||||
void ProcessMouseEvent (SDL_Event* event);
|
||||
void ProcessTextEvent (SDL_Event* event);
|
||||
void ProcessTouchEvent (SDL_Event* event);
|
||||
void ProcessWindowEvent (SDL_Event* event);
|
||||
|
||||
@@ -54,6 +56,7 @@ namespace lime {
|
||||
MouseEvent mouseEvent;
|
||||
double nextUpdate;
|
||||
RenderEvent renderEvent;
|
||||
TextEvent textEvent;
|
||||
TouchEvent touchEvent;
|
||||
UpdateEvent updateEvent;
|
||||
WindowEvent windowEvent;
|
||||
|
||||
@@ -115,6 +115,13 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
bool SDLWindow::GetEnableTextEvents () {
|
||||
|
||||
return SDL_IsTextInputActive ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
int SDLWindow::GetHeight () {
|
||||
|
||||
int width;
|
||||
@@ -177,6 +184,21 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void SDLWindow::SetEnableTextEvents (bool enabled) {
|
||||
|
||||
if (enabled) {
|
||||
|
||||
SDL_StartTextInput ();
|
||||
|
||||
} else {
|
||||
|
||||
SDL_StopTextInput ();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool SDLWindow::SetFullscreen (bool fullscreen) {
|
||||
|
||||
if (fullscreen) {
|
||||
|
||||
@@ -18,12 +18,14 @@ namespace lime {
|
||||
~SDLWindow ();
|
||||
|
||||
virtual void Close ();
|
||||
virtual bool GetEnableTextEvents ();
|
||||
virtual int GetHeight ();
|
||||
virtual int GetWidth ();
|
||||
virtual int GetX ();
|
||||
virtual int GetY ();
|
||||
virtual void Move (int x, int y);
|
||||
virtual void Resize (int width, int height);
|
||||
virtual void SetEnableTextEvents (bool enabled);
|
||||
virtual bool SetFullscreen (bool fullscreen);
|
||||
virtual void SetIcon (ImageBuffer *imageBuffer);
|
||||
virtual bool SetMinimized (bool minimized);
|
||||
|
||||
Reference in New Issue
Block a user