Add a dedicated text input event. Switch to our own custom keycode enum rather than depending on SDLs.
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5445 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
c8dbcd6d2d
commit
631ff7879b
|
@ -788,6 +788,7 @@ bool widgetHandleEventImpl(widget *self, event *evt)
|
|||
}
|
||||
case EVT_KEY_DOWN:
|
||||
case EVT_KEY_UP:
|
||||
case EVT_TEXT:
|
||||
{
|
||||
// Only relevant if we have focus
|
||||
if (self->hasFocus)
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "vector.h"
|
||||
#include "geom.h"
|
||||
|
||||
#include "keycode.h"
|
||||
|
||||
/*
|
||||
* Forward declarations
|
||||
*/
|
||||
|
@ -26,6 +28,7 @@ typedef struct _event event;
|
|||
typedef struct _eventMouse eventMouse;
|
||||
typedef struct _eventMouseBtn eventMouseBtn;
|
||||
typedef struct _eventKey eventKey;
|
||||
typedef struct _eventText eventText;
|
||||
typedef struct _eventMisc eventMisc;
|
||||
|
||||
typedef bool (*callback) (widget *widget, event *evt, void *userData);
|
||||
|
@ -58,6 +61,9 @@ enum _eventType
|
|||
// Keyboard events
|
||||
EVT_KEY_DOWN,
|
||||
EVT_KEY_UP,
|
||||
|
||||
// Text input events
|
||||
EVT_TEXT,
|
||||
|
||||
// Misc
|
||||
EVT_FOCUS,
|
||||
|
@ -125,12 +131,8 @@ struct _eventKey
|
|||
{
|
||||
event event;
|
||||
|
||||
// The key which was pressed, this should be used for text-input &c
|
||||
// NB: This is only valid for EVT_KEY_DOWN events!
|
||||
int unicode;
|
||||
|
||||
// The keycode of the key which was pressed
|
||||
int keycode;
|
||||
eventKeycode keycode;
|
||||
|
||||
// Active modifier keys
|
||||
bool ctrl;
|
||||
|
@ -138,6 +140,17 @@ struct _eventKey
|
|||
bool alt;
|
||||
};
|
||||
|
||||
/*
|
||||
* The event structure for text input events
|
||||
*/
|
||||
struct _eventText
|
||||
{
|
||||
event event;
|
||||
|
||||
// The text that was typed, UTF-8 encoded
|
||||
const char *utf8;
|
||||
};
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue