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
This commit is contained in:
		
							parent
							
								
									cdd8a3276c
								
							
						
					
					
						commit
						bd9541cc04
					
				
							
								
								
									
										1
									
								
								global.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								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)))
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										4
									
								
								input.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								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;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										1
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								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)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								readline.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								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<max_size)? size:size-1;
 | 
			
		||||
@ -176,14 +179,14 @@ byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_siz
 | 
			
		||||
        visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
 | 
			
		||||
  Flush_update();
 | 
			
		||||
 | 
			
		||||
  while ((input_key!=SDLK_RETURN) && (input_key!=KEY_ESC))
 | 
			
		||||
  while ((input_key!=SDLK_RETURN) && (input_key!=KEY_ESC) && Mouse_K == 0)
 | 
			
		||||
  {
 | 
			
		||||
    Display_cursor();
 | 
			
		||||
    do
 | 
			
		||||
    {
 | 
			
		||||
      if(!Get_input()) SDL_Delay(20);
 | 
			
		||||
      input_key=Key_ANSI;
 | 
			
		||||
    } while(input_key==0);
 | 
			
		||||
    } while(input_key==0 && Mouse_K == 0);
 | 
			
		||||
    Hide_cursor();
 | 
			
		||||
    switch (input_key)
 | 
			
		||||
    {
 | 
			
		||||
@ -325,6 +328,7 @@ affichage:
 | 
			
		||||
    Flush_update();
 | 
			
		||||
 | 
			
		||||
  } // End du "while"
 | 
			
		||||
  Keyboard_click_allowed = 1;
 | 
			
		||||
 | 
			
		||||
  // Effacement de la chaîne
 | 
			
		||||
  Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
 | 
			
		||||
@ -346,5 +350,5 @@ affichage:
 | 
			
		||||
  Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
 | 
			
		||||
        visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
 | 
			
		||||
 | 
			
		||||
  return (input_key==SDLK_RETURN);
 | 
			
		||||
  return (input_key==SDLK_RETURN || Mouse_K != 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user