forked from MapComplete/MapComplete
		
	Small fixes in cursor position calculation
This commit is contained in:
		
							parent
							
								
									558a1848a0
								
							
						
					
					
						commit
						478b82b1e1
					
				
					 1 changed files with 3 additions and 6 deletions
				
			
		|  | @ -92,16 +92,14 @@ export class TextField extends InputElement<string> { | |||
|              | ||||
|             // @ts-ignore
 | ||||
|             val = field.value; | ||||
|             let newCursorPos = endDistance; | ||||
|             let newCursorPos = val.length - endDistance; | ||||
|             while(newCursorPos >= 0 &&  | ||||
|                 // We count the number of _actual_ characters (non-space characters) on the right of the new value
 | ||||
|                 // This count should become bigger then the end distance
 | ||||
|                 val.substr(newCursorPos).replace(/ /g, '').length <= endDistance | ||||
|                 val.substr(newCursorPos).replace(/ /g, '').length < endDistance | ||||
|                 ){ | ||||
|                 newCursorPos --; | ||||
|             } | ||||
|             newCursorPos++; | ||||
|              | ||||
|             // @ts-ignore
 | ||||
|             self.SetCursorPosition(newCursorPos); | ||||
|         }; | ||||
|  | @ -147,4 +145,3 @@ export class TextField extends InputElement<string> { | |||
|     } | ||||
| 
 | ||||
| } | ||||
|                  | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue