From bd9541cc047067739c3d12ccc7a2a4fc54db6466 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Fri, 24 Jul 2009 15:22:18 +0000 Subject: [PATCH] Allows exiting a textfield with a mouse click (but not using space). Introduce a new global var to do it, however... git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@952 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- global.h | 1 + input.c | 4 ++-- main.c | 1 + readline.c | 10 +++++++--- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/global.h b/global.h index 5b1632ba..8887d7b5 100644 --- a/global.h +++ b/global.h @@ -78,6 +78,7 @@ GFX2_GLOBAL T_Components Fav_menu_colors[4]; GFX2_GLOBAL word Mouse_X; ///< Current mouse cursor position. GFX2_GLOBAL word Mouse_Y; ///< Current mouse cursor position. GFX2_GLOBAL byte Mouse_K; ///< Current mouse buttons state. Bitfield: 1 for RMB, 2 for LMB. +GFX2_GLOBAL byte Keyboard_click_allowed; ///< Set to 0 when you edit a textfield so you can use space without exiting it /// Helper macro to take only one button when both are pressed (LMB has priority) #define Mouse_K_unique (Mouse_K==0?0:(Mouse_K&1?1:(Mouse_K&2?2:0))) diff --git a/input.c b/input.c index 34148178..8900406f 100644 --- a/input.c +++ b/input.c @@ -345,13 +345,13 @@ int Handle_key_press(SDL_KeyboardEvent event) Directional_right=1; return 0; } - else if(Is_shortcut(Key,SPECIAL_CLICK_LEFT)) + else if(Is_shortcut(Key,SPECIAL_CLICK_LEFT) && Keyboard_click_allowed > 0) { Input_new_mouse_K=1; Directional_click=1; return Move_cursor_with_constraints(); } - else if(Is_shortcut(Key,SPECIAL_CLICK_RIGHT)) + else if(Is_shortcut(Key,SPECIAL_CLICK_RIGHT) && Keyboard_click_allowed > 0) { Input_new_mouse_K=2; Directional_click=2; diff --git a/main.c b/main.c index b2d4754a..38e944c8 100644 --- a/main.c +++ b/main.c @@ -398,6 +398,7 @@ int Init_program(int argc,char * argv[]) Spare_magnifier_width=0; Spare_magnifier_offset_X=0; Spare_magnifier_offset_Y=0; + Keyboard_click_allowed = 0; // SDL if(SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0) diff --git a/readline.c b/readline.c index 15c2e291..dd7e4f8c 100644 --- a/readline.c +++ b/readline.c @@ -158,6 +158,9 @@ byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_siz else if (input_type==1) snprintf(str,10,"%d",atoi(str)); // On tasse la chaine à gauche + Wait_end_of_click(); + Keyboard_click_allowed = 0; + size=strlen(str); position=(size