Skip to content

Opening new suggestion window hijacks written text #3

@xhruso00

Description

@xhruso00

When a new suggestion window opens and mouse is inside window mouseEntered causes that currently written text is hijacked and replaced with suggestion. The proper solution is to mark down lastMouseOverView and only mark it as selected when user moves mouse (need to change window settings to acceptmousemoved). Safari behaves the same.

The issue with hijack text I have with MKLocalSearchCompleter as it can give suggestions that don't match the text user has typed

override func mouseEntered(with event: NSEvent) {
    lastMouseEnteredView = event.trackingArea?.userInfo?[SuggestionWindowController.trackerKey] as? NSView
    // NOTE: THIS CAUSES ISSUE DURING TYPING AND MOUSE IS OVER SUGGESTION WINDOW
    //userSetSelectedView(lastMouseEnteredView)
}

override func mouseMoved(with event: NSEvent) {
    guard selectedView == nil, let lastMouseEnteredView  else { return }
    
    userSetSelectedView(lastMouseEnteredView)
}

/* The mouse has left one of our child image views. Set the selection to no selection and send action
 */
override func mouseExited(with event: NSEvent) {
    lastMouseEnteredView = nil
    guard let win = self.window, win.isVisible else { return }
    
    userSetSelectedView(nil)
}

https://github.com/jbrayton/CustomMenus/blob/ebb88c3c87e9461410882fab31c91dde4bef9309/Suggestion List Window/SUGSuggestionListWindowController.swift#L316

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