Coordinator
class Coordinator: NSObject, NSTextViewDelegate
The coordinator for the ChordProEditor
-
The text of the editor
Declaration
Swift
var text: Binding<String>
-
The connector class for the editor
Declaration
Swift
var connector: ChordProEditor.Connector
-
The optional balance string, close a
{
or[
Declaration
Swift
var balance: String?
-
Bool if the whole text must be (re)highlighed or just the current fragment
Declaration
Swift
var fullHighlight: Bool = true
-
Debouncer for the text update
Declaration
Swift
private var task: Task<Void, Never>?
-
Init the coordinator
Declaration
Swift
public init(text: Binding<String>, connector: ChordProEditor.Connector)
Parameters
parent
The
ChordProEditor
-
Protocol function to check if a text should change
Declaration
Swift
func textView( _ textView: NSTextView, shouldChangeTextIn affectedCharRange: NSRange, replacementString: String? ) -> Bool
Parameters
textView
The
NSTextView
affectedCharRange
The character range that is affected
replacementString
The optional replacement string
Return Value
True or false
-
Protocol function with a notification that the text has changed
Declaration
Swift
func textDidChange(_ notification: Notification)
Parameters
notification
The notification with the
NSTextView
as object -
Protocol function with a notification that the text selection has changed
Declaration
Swift
func textViewDidChangeSelection(_ notification: Notification)
Parameters
notification
The notification with the
NSTextView
as object -
Update the text binding with the current text from the `NSTextView
Note
With a debounce of one second to prevent too many updatesDeclaration
Swift
func updateTextBinding()