Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 19, 2025

This PR fixes an issue where using Apple Pencil on iPad with floating keyboard mode causes the page to freeze after the keyboard is dismissed.

Problem

When using iPad in floating keyboard mode:

  1. User taps text field to show floating keyboard
  2. User taps elsewhere with Apple Pencil to dismiss keyboard
  3. Keyboard disappears but the entire page becomes unresponsive and freezes

This was happening because the gesture recognizer was attempting to handle Apple Pencil touches, which interfered with the system's native floating keyboard behavior.

Solution

Added Apple Pencil touch filtering in the shouldReceiveTouch gesture recognizer delegate method for both Swift and Objective-C versions:

Swift version:

// Ignore Apple Pencil touches to prevent conflicts with floating keyboard on iPad
if #available(iOS 9.1, *) {
    if touch.type == .pencil {
        return false
    }
}

Objective-C version:

// Ignore Apple Pencil touches to prevent conflicts with floating keyboard on iPad
if (@available(iOS 9.1, *)) {
    if (touch.type == UITouchTypePencil) {
        return NO;
    }
}

Benefits

  • Minimal Impact: Only 14 lines of code added across both implementations
  • Backward Compatible: Uses availability checks for iOS 9.1+ (when Apple Pencil was introduced)
  • Preserves Functionality: Finger touches and other input methods continue to work normally
  • Consistent: Applied the same fix to both Swift and Objective-C versions

The fix allows the system's native floating keyboard handling to work without interference while maintaining all existing touch-to-dismiss functionality for finger touches.

Fixes #2109.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] iPad 浮动键盘模式下,连接蓝牙笔applepencil,蓝牙笔点击后页面卡死,无法操作 Fix iPad floating keyboard freeze when using Apple Pencil touches Sep 19, 2025
Copilot AI requested a review from hackiftekhar September 19, 2025 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iPad 浮动键盘模式下,连接蓝牙笔applepencil,蓝牙笔点击后页面卡死,无法操作

2 participants