 import UIKit
 
 @objc public protocol MathInputViewDelegate: NSObjectProtocol {
-    func mathInputView(_ MathInputView: MathInputView, didParse ink: [Any], latex: String)
-    func mathInputView(_ MathInputView: MathInputView, didFailToParse ink: [Any], with error: NSError)
+    func mathInputView(_ mathInputView: MathInputView, didParse ink: [Any], latex: String)
+    func mathInputView(_ mathInputView: MathInputView, didFailToParse ink: [Any], with error: NSError)
+    func mathInputView(_ mathInputView: MathInputView, didChangeModeTo isWritingMode: Bool)
 }
 
 open class MathInputView: UIView, MathInkManagerDelegate {

            tapGestureRecognizer.isEnabled = !newValue
            longPressGestureRecognizer.isEnabled = !newValue
        }
    }
    
    open var manager = MathInkManager()

    // MARK: - Touch
    
    override open func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        guard isWritingMode else { return }
        register(touch: touches.first!)
    }
    
    override open func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
        if !isWritingMode { isWritingMode = true }
        register(touch: touches.first!)
    }
    
    override open func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
        guard isWritingMode else { return }
        register(touch: touches.first!, isLast: true)
        manager.process()
    }
    
    override open func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
        guard isWritingMode else { return }
        register(touch: touches.first!, isLast: true)
        manager.process()
    }
