From b0747a70a2422fcbad2febb07e33c9f43c3b797c Mon Sep 17 00:00:00 2001 From: Jason Foster Date: Mon, 24 Nov 2025 20:56:17 +0000 Subject: [PATCH] Fix iOS touch ID stability Touch IDs were using loop indices (0, 1, 2...) which caused them to change when touches were added or removed. This broke multitouch tracking for applications trying to follow individual fingers. Now using the UITouch pointer as a stable identifier that persists for the lifetime of each touch. --- src/native/ios.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/native/ios.rs b/src/native/ios.rs index 469b1fe4..01ad00eb 100644 --- a/src/native/ios.rs +++ b/src/native/ios.rs @@ -136,8 +136,10 @@ pub fn define_glk_or_mtk_view(superclass: &Class) -> *const Class { let size: u64 = msg_send![enumerator, count]; let enumerator: ObjcId = msg_send![enumerator, objectEnumerator]; - for touch_id in 0..size { + for _ in 0..size { let ios_touch: ObjcId = msg_send![enumerator, nextObject]; + // Use the UITouch pointer as a stable ID instead of loop index + let touch_id = ios_touch as u64; let mut ios_pos: NSPoint = msg_send![ios_touch, locationInView: this]; if native_display().lock().unwrap().high_dpi {