From c6eb611d8fbfd5825ea96f8d660bef4a6c45be1d Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Fri, 20 Jul 2007 22:30:11 +0000 Subject: [PATCH] fixed some bugs --- src/game/client/menu.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/game/client/menu.cpp b/src/game/client/menu.cpp index 1a6243c98..9e1b34e66 100644 --- a/src/game/client/menu.cpp +++ b/src/game/client/menu.cpp @@ -243,9 +243,12 @@ struct server_list int ui_do_key_reader(void *id, float x, float y, float w, float h, int key) { // process - static bool can_be_selected = true; + static bool mouse_released = true; int inside = ui_mouse_inside(x, y, w, h); int new_key = key; + + if(!ui_mouse_button(0)) + mouse_released = true; if(ui_active_item() == id) { @@ -254,19 +257,18 @@ int ui_do_key_reader(void *id, float x, float y, float w, float h, int key) { new_key = k; ui_set_active_item(0); - can_be_selected = false; + mouse_released = false; } } else if(ui_hot_item() == id) { - if(ui_mouse_button(0)) + if(ui_mouse_button(0) && mouse_released) ui_set_active_item(id); } if(inside) ui_set_hot_item(id); - // draw draw_box(GUI_BOX_SCREEN_INFO, tileset_regular, x, y, w, h); @@ -329,7 +331,7 @@ int ui_do_edit_box(void *id, float x, float y, float w, float h, char *str, int int inside = ui_mouse_inside(x, y, w, h); int r = 0; - if (ui_active_item() == id) + if(ui_last_active_item() == id) { int c = input::last_char(); int k = input::last_key(); @@ -351,6 +353,12 @@ int ui_do_edit_box(void *id, float x, float y, float w, float h, char *str, int } r = 1; } + + if(ui_active_item() == id) + { + if(!ui_mouse_button(0)) + ui_set_active_item(0); + } else if(ui_hot_item() == id) { if(ui_mouse_button(0)) @@ -358,13 +366,13 @@ int ui_do_edit_box(void *id, float x, float y, float w, float h, char *str, int } if(inside) - ui_set_hot_item(id); + ui_set_hot_item(id); draw_box(GUI_BOX_SCREEN_TEXTBOX, tileset_regular, x, y, w, h); ui_do_label(x + 10, y, str, 36); - if (ui_active_item() == id) + if (ui_last_active_item() == id) { float w = gfx_pretty_text_width(36.0f, str); ui_do_label(x + 10 + w, y, "_", 36);