diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d2faa85d9..0cff276ed 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -5,6 +5,7 @@ D2X-Rebirth Changelog include/ui.h, ui/button.c, ui/dialog.c, ui/gadget.c, ui/scroll.c, ui/userbox.c: Make B1_JUST_PRESSED event-based, leave ui_dialog_do_gadgets early if a key makes another gadget current, make ui_button_do fully event-responsive (but won't *send* events yet) editor/med.c: Put back use of med_show_warning for Linux, but then clear it properly when leaving the editor ui/checkbox.c: Make ui_checkbox_do fully event-responsive +ui/checkbox.c, ui/icon.c: Fix implicit function declaration in last commit, make ui_icon_do fully event-responsive 20111103 -------- diff --git a/ui/checkbox.c b/ui/checkbox.c index 2ba6c0ec2..6d7369792 100644 --- a/ui/checkbox.c +++ b/ui/checkbox.c @@ -25,6 +25,7 @@ static char rcsid[] = "$Id: checkbox.c,v 1.1.1.1 2006/03/17 19:52:20 zicodxx Exp #include "event.h" #include "gr.h" #include "ui.h" +#include "mouse.h" #include "key.h" #define Middle(x) ((2*(x)+1)/4) diff --git a/ui/icon.c b/ui/icon.c index ad0c4d03a..f6bd260f7 100644 --- a/ui/icon.c +++ b/ui/icon.c @@ -25,6 +25,7 @@ static char rcsid[] = "$Id: icon.c,v 1.1.1.1 2006/03/17 19:52:19 zicodxx Exp $"; #include "event.h" #include "gr.h" #include "ui.h" +#include "mouse.h" #include "key.h" #define Middle(x) ((2*(x)+1)/4) @@ -93,7 +94,7 @@ UI_GADGET_ICON * ui_add_gadget_icon( UI_DIALOG * dlg, char * text, short x, shor icon->width = w; icon->height = h; - MALLOC( icon->text, char, strlen( text )+2); + MALLOC( icon->text, char, strlen( text )+2);//Hack by KRB strcpy( icon->text, text ); icon->trap_key = k; icon->user_function = f; @@ -118,34 +119,61 @@ UI_GADGET_ICON * ui_add_gadget_icon( UI_DIALOG * dlg, char * text, short x, shor int ui_icon_do( UI_GADGET_ICON * icon, d_event *event ) { - int OnMe; - int keypress = 0; int rval = 0; - if (event->type == EVENT_KEY_COMMAND) - keypress = event_key_get(event); - - OnMe = ui_mouse_on_gadget( (UI_GADGET *)icon ); - icon->oldposition = icon->position; - - if ( B1_PRESSED && OnMe ) - { - icon->position = 1; - } else { - icon->position = 0; - } - icon->pressed = 0; - if ((icon->position==0) && (icon->oldposition==1) && OnMe ) - icon->pressed = 1; + if (event->type == EVENT_MOUSE_BUTTON_DOWN || event->type == EVENT_MOUSE_BUTTON_UP) + { + int OnMe; + + OnMe = ui_mouse_on_gadget( (UI_GADGET *)icon ); - if (icon->pressed == 1 || keypress==icon->trap_key ) + if (B1_JUST_PRESSED && OnMe) + { + icon->position = 1; + rval = 1; + } + else if (B1_JUST_RELEASED) + { + if ((icon->position == 1) && OnMe) + icon->pressed = 1; + + icon->position = 0; + } + } + + + if (event->type == EVENT_KEY_COMMAND) + { + int key; + + key = event_key_get(event); + + if (key == icon->trap_key) + { + icon->position = 1; + rval = 1; + } + } + else if (event->type == EVENT_KEY_RELEASE) + { + int key; + + key = event_key_get(event); + + icon->position = 0; + + if (key == icon->trap_key) + icon->pressed = 1; + } + + if (icon->pressed == 1) { icon->status = 1; icon->flag = (sbyte)icon->user_function(); - if (keypress==icon->trap_key) last_keypress = 0; + rval = 1; } ui_draw_icon( icon );