[Fix] No-one knew it, but input for toolkit was buggy. Seperated toolkit input from game input to fix this.

This commit is contained in:
Allanis 2013-02-27 14:50:16 +00:00
parent ddadb068fe
commit fb57dde3ed
3 changed files with 20 additions and 8 deletions

View File

@ -298,6 +298,11 @@ static void input_keyup(SDLKey key) {
// Just seperates the event types. // Just seperates the event types.
void input_handle(SDL_Event* event) { void input_handle(SDL_Event* event) {
if(toolkit) {
// Toolkit is handled seperately.
toolkit_input(event);
return;
}
switch(event->type) { switch(event->type) {
case SDL_JOYAXISMOTION: case SDL_JOYAXISMOTION:
input_joyaxis(event->jaxis.axis, event->jaxis.value); input_joyaxis(event->jaxis.axis, event->jaxis.value);
@ -314,12 +319,6 @@ void input_handle(SDL_Event* event) {
case SDL_KEYUP: case SDL_KEYUP:
input_keyup(event->key.keysym.sym); input_keyup(event->key.keysym.sym);
break; break;
// Toolkit.
case SDL_MOUSEMOTION:
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
if(toolkit) toolkit_mouseEvent(event);
break;
} }
} }

View File

@ -75,6 +75,8 @@ static int mwindows = 0;
static Widget* window_newWidget(Window* w); static Widget* window_newWidget(Window* w);
static void widget_cleanup(Widget* widget); static void widget_cleanup(Widget* widget);
static Window* window_wget(const unsigned int wid); static Window* window_wget(const unsigned int wid);
// Input.
static void toolkit_mouseEvent(SDL_Event* event);
// Render. // Render.
static void window_render(Window* w); static void window_render(Window* w);
static void toolkit_renderButton(Widget* btn, double bx, double by); static void toolkit_renderButton(Widget* btn, double bx, double by);
@ -502,6 +504,7 @@ static void window_render(Window* w) {
} }
} }
// Renders a button.
static void toolkit_renderButton(Widget* btn, double bx, double by) { static void toolkit_renderButton(Widget* btn, double bx, double by) {
glColour* c, *dc, *oc, *lc; glColour* c, *dc, *oc, *lc;
double x, y; double x, y;
@ -670,9 +673,19 @@ void toolkit_render(void) {
} }
void toolkit_input(SDL_Event* event) {
switch(event->type) {
case SDL_MOUSEMOTION:
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
toolkit_mouseEvent(event);
break;
}
}
// Input. // Input.
static int mouse_down = 0; static int mouse_down = 0;
void toolkit_mouseEvent(SDL_Event* event) { static void toolkit_mouseEvent(SDL_Event* event) {
int i; int i;
double x, y; double x, y;
Window* w; Window* w;

View File

@ -31,7 +31,7 @@ void window_destroyWidget(unsigned wid, const char* wgtname);
void toolkit_render(void); void toolkit_render(void);
// Input. // Input.
void toolkit_mouseEvent(SDL_Event* event); void toolkit_input(SDL_Event* event);
// Init/Exit. // Init/Exit.
int toolkit_init(void); int toolkit_init(void);