Various Fixes

This commit is contained in:
Ilya Laktyushin
2021-02-18 17:35:31 +04:00
parent dafbfe44d1
commit 2f1304a8e6
6 changed files with 30 additions and 15 deletions

View File

@@ -14,6 +14,7 @@ import TouchDownGesture
import ImageTransparency
import ActivityIndicator
import AnimationUI
import Speak
private let accessoryButtonFont = Font.medium(14.0)
private let counterFont = Font.with(size: 14.0, design: .regular, traits: [.monospacedNumbers])
@@ -1775,7 +1776,18 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
}
func editableTextNodeTarget(forAction action: Selector) -> ASEditableTextNodeTargetForAction? {
if action == Selector(("_showTextStyleOptions:")) {
if action == Selector(("_accessibilitySpeak:")) {
if let textInputNode = self.textInputNode, textInputNode.selectedRange.length > 0 {
return ASEditableTextNodeTargetForAction(target: self)
} else {
return ASEditableTextNodeTargetForAction(target: nil)
}
} else if action == Selector("_accessibilitySpeakLanguageSelection:") {
return ASEditableTextNodeTargetForAction(target: nil)
} else if action == Selector("_accessibilityPauseSpeaking:") {
return ASEditableTextNodeTargetForAction(target: nil)
}
else if action == Selector(("_showTextStyleOptions:")) {
if case .general = self.inputMenu.state {
if let textInputNode = self.textInputNode, textInputNode.attributedText == nil || textInputNode.attributedText!.length == 0 || textInputNode.selectedRange.length == 0 {
return ASEditableTextNodeTargetForAction(target: nil)
@@ -1797,6 +1809,15 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
return nil
}
@objc func _accessibilitySpeak(_ sender: Any) {
var text = ""
self.interfaceInteraction?.updateTextInputStateAndMode { current, inputMode in
text = current.inputText.attributedSubstring(from: NSMakeRange(current.selectionRange.lowerBound, current.selectionRange.count)).string
return (current, inputMode)
}
speakText(text)
}
@objc func _showTextStyleOptions(_ sender: Any) {
if let textInputNode = self.textInputNode {
self.inputMenu.format(view: textInputNode.view, rect: textInputNode.selectionRect.offsetBy(dx: 0.0, dy: -textInputNode.textView.contentOffset.y).insetBy(dx: 0.0, dy: -1.0))