Skip to content

Moving mouse outside suggestion window should restore originally user typed string #4

@xhruso00

Description

@xhruso00

Example:

@objc private func updateWithSelectedSuggestion(_ sender: SuggestionWindowController?) {
    guard let fieldEditor = window?.fieldEditor(false, for: self) else { return }
    
    if let suggestion = sender?.selectedSuggestion() as? MKLocalSearchCompletion {
        updateFieldEditor(fieldEditor, with: suggestion.title)
        selectedSuggestion = suggestion
    } else {
        fieldEditor.string = userTypedString
        fieldEditor.selectedRange = NSMakeRange(userTypedString.count, 0)
        selectedSuggestion = nil
    }
}

public override func textDidChange(_ notification: Notification) {
    userTypedString = stringValue
    super.textDidChange(notification)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions