[Add] Input widget will scoll if full.
This commit is contained in:
		
							parent
							
								
									ab0ecfdede
								
							
						
					
					
						commit
						e3618d7559
					
				| @ -16,7 +16,7 @@ | ||||
| #define MENU_WIDTH          130 | ||||
| #define MENU_HEIGHT         200 | ||||
| 
 | ||||
| #define INFO_WIDTH          320 | ||||
| #define INFO_WIDTH          360 | ||||
| #define INFO_HEIGHT         280 | ||||
| 
 | ||||
| #define OUTFITS_WIDTH   400 | ||||
|  | ||||
| @ -921,7 +921,7 @@ static void toolkit_renderInput(Widget* inp, double bx, double by) { | ||||
| 
 | ||||
|   gl_printText(&gl_smallFont, inp->w-10., inp->h, | ||||
|                x+5. + gl_screen.w/2., ty + gl_screen.h/2., | ||||
|                &cBlack, inp->dat.inp.input); | ||||
|                &cBlack, inp->dat.inp.input+inp->dat.inp.view); | ||||
| 
 | ||||
|   // Inner outline.
 | ||||
|   toolkit_drawOutline(x, y, inp->w, inp->h, 0., | ||||
| @ -933,6 +933,7 @@ static void toolkit_renderInput(Widget* inp, double bx, double by) { | ||||
| 
 | ||||
| // Handle input for input widget.
 | ||||
| static int toolkit_inputInput(Uint8 type, Widget* inp, SDLKey key) { | ||||
|   int n; | ||||
|   SDLMod mods; | ||||
| 
 | ||||
|   if(inp->type != WIDGET_INPUT) return 0; | ||||
| @ -940,8 +941,16 @@ static int toolkit_inputInput(Uint8 type, Widget* inp, SDLKey key) { | ||||
|   mods = SDL_GetModState(); | ||||
|   if(inp->dat.inp.oneline && isascii(key)) { | ||||
|     // Backspace -> delete text.
 | ||||
|     if((type == SDL_KEYDOWN) && (key == '\b') && (inp->dat.inp.pos > 0)) | ||||
|     if((type == SDL_KEYDOWN) && (key == '\b') && (inp->dat.inp.pos > 0)) { | ||||
|       inp->dat.inp.input[--inp->dat.inp.pos] = '\0'; | ||||
| 
 | ||||
|       if(inp->dat.inp.view > 0) { | ||||
|         n = gl_printWidth(&gl_smallFont, | ||||
|             inp->dat.inp.input + inp->dat.inp.view - 1); | ||||
|         if(n+10 < inp->w) | ||||
|           inp->dat.inp.view--; | ||||
|       } | ||||
|     } | ||||
|     else if((type == SDL_KEYDOWN) && (inp->dat.inp.pos < inp->dat.inp.max-1)) { | ||||
|       if((key == SDLK_RETURN) && !inp->dat.inp.oneline) | ||||
|         inp->dat.inp.input[inp->dat.inp.pos++] = '\n'; | ||||
| @ -957,6 +966,8 @@ static int toolkit_inputInput(Uint8 type, Widget* inp, SDLKey key) { | ||||
|       // Didn't get a useful key.
 | ||||
|       else return 0; | ||||
| 
 | ||||
|       n = gl_printWidth(&gl_smallFont, inp->dat.inp.input+inp->dat.inp.view); | ||||
|       if(n + 10 > inp->w) inp->dat.inp.view++; | ||||
|       return 1; | ||||
|     } | ||||
|   } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Allanis
						Allanis