You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/Runestone/TextView/TextInput/TextInputView.swift
+20-40Lines changed: 20 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -31,11 +31,12 @@ final class TextInputView: UIView, UITextInput {
31
31
}
32
32
}
33
33
set{
34
-
// We should not use this setter. It's intended for UIKit to use. It'll invoke the setter in various scenarios, for example when navigating the text using the keyboard.
34
+
// We should not use this setter. It's intended for UIKit to use.
35
+
// It'll invoke the setter in various scenarios, for example when navigating the text using the keyboard.
@@ -606,6 +603,13 @@ final class TextInputView: UIView, UITextInput {
606
603
layoutManager.layoutIfNeeded()
607
604
layoutManager.layoutLineSelectionIfNeeded()
608
605
layoutPageGuideIfNeeded()
606
+
// We notify the input delegate about selection changes in layoutSubviews so we have a chance of disabling notifying the input delegate during an editing operation.
607
+
// We will sometimes disable notifying the input delegate when the user enters Korean text.
608
+
// This workaround is inspired by a dialog with Alexander Blach (@lextar), developer of Textastic.
609
+
if shouldNotifyInputDelegateAboutSelectionChangeInLayoutSubviews {
610
+
inputDelegate?.selectionWillChange(self)
611
+
inputDelegate?.selectionDidChange(self)
612
+
}
609
613
}
610
614
611
615
overridefunc copy(_ sender:Any?){
@@ -617,18 +621,14 @@ final class TextInputView: UIView, UITextInput {
// Disable notifying delegate in layout subviews to prevent issues when entering Korean text. This workaround is inspired by a dialog with Alexander Black (@lextar), developer of Textastic.
// Fores the position of the caret to be updated. Normally we can do this by notifying the input delegate when changing the selected range like:
1176
-
//
1177
-
// inputDelegate?.selectionWillChange(self)
1178
-
// selectedRange = newSelectedRange
1179
-
// inputDelegate?.selectionDidChange(self)
1180
-
//
1181
-
// If we don't notify the input delegate when the setter on selectedTextRange is called, then the location of the caret will not be updated.
1182
-
// However, if we do notify the delegate when the setter is called, Korean input will no longer work as described in https://github.com/simonbs/Runestone/issues/11
1183
-
// So the workaround is to not notify the delegate but tell the text selection view directly that the selection has changed.
1184
-
iflet textSelectionView = textSelectionView {
1185
-
letsel=NSSelectorFromString("selectionChanged")
1186
-
if textSelectionView.responds(to: sel){
1187
-
textSelectionView.perform(sel)
1188
-
}else{
1189
-
print("\(textSelectionView) does not respond to 'selectionChanged'")
0 commit comments