mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-31 05:31:01 +00:00 
			
		
		
		
	[HTML5] Fix input not focusing canvas.
mousedown and touchstart should focus the canvas to ensure correct application lifecycle.
This commit is contained in:
		
							parent
							
								
									ba798d585c
								
							
						
					
					
						commit
						f13c7fc83e
					
				
					 1 changed files with 6 additions and 0 deletions
				
			
		|  | @ -389,6 +389,9 @@ const GodotInput = { | |||
| 			const rect = canvas.getBoundingClientRect(); | ||||
| 			const pos = GodotInput.computePosition(evt, rect); | ||||
| 			const modifiers = GodotInput.getModifiers(evt); | ||||
| 			if (p_pressed && document.activeElement !== GodotConfig.canvas) { | ||||
| 				GodotConfig.canvas.focus(); | ||||
| 			} | ||||
| 			if (func(p_pressed, evt.button, pos[0], pos[1], modifiers)) { | ||||
| 				evt.preventDefault(); | ||||
| 			} | ||||
|  | @ -405,6 +408,9 @@ const GodotInput = { | |||
| 		const func = GodotRuntime.get_func(callback); | ||||
| 		const canvas = GodotConfig.canvas; | ||||
| 		function touch_cb(type, evt) { | ||||
| 			if (type === 0 && document.activeElement !== GodotConfig.canvas) { | ||||
| 				GodotConfig.canvas.focus(); | ||||
| 			} | ||||
| 			const rect = canvas.getBoundingClientRect(); | ||||
| 			const touches = evt.changedTouches; | ||||
| 			for (let i = 0; i < touches.length; i++) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Fabio Alessandrelli
						Fabio Alessandrelli