Repository navigation
Conversation
Right-clicking a candidate now opens a context menu whose single item forgets that candidate, via the librime API that Squirrel had not been wiring up so far: RimeApi.delete_candidate_on_current_page(session, index) Hit testing reuses SquirrelView.click(at:), the same path the existing left-click selection goes through. The panel is created at CGShieldingWindowLevel, which is far above the level AppKit assigns to pop-up menus, so the menu would otherwise be drawn behind the candidate panel. Lower the panel to popUpMenu - 1 for the duration of menu tracking and restore it afterwards; 100 is still above ordinary application windows, so the panel is not covered by the client app while the menu is open.
Member
|
Mark 一下,有空我測測,這個有意思 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Right-clicking a candidate opens a context menu with a single item that
forgets that candidate.
This wires up a librime API that Squirrel has never called:
Weasel has exposed the same operation as
Shift+Deletefor a long time;Squirrel had no entry point for it at all.
Implementation notes
SquirrelInputController.deleteCandidate(_:)is deliberately symmetricwith the existing
selectCandidate(_:).SquirrelView.click(at:), the same path left-clickselection already goes through.
CGShieldingWindowLevel(),which is far above the level AppKit assigns to pop-up menus, so the
menu would be drawn behind the candidate panel. The panel is lowered
to
NSWindow.Level.popUpMenu - 1for the duration of menu tracking andrestored afterwards. 100 is still above ordinary application windows,
so the panel is not covered by the client app while the menu is open.
NSApp.activate. Activating wouldpull focus away from the client app and break the input session.
Only deletion is implemented. There is no pin-to-top counterpart because
librime exposes no such API — candidate ordering is decided by translator
weights and user-dictionary learning, and a frontend cannot override it.
Testing
This has not been built or run. It was written on a machine with no
Xcode installed, so verification stopped at
swiftc -parse. Two thingsneed checking on a real build before this is merged:
NSMenu.popUp(positioning:at:in:)tracks correctly from anon-activating panel in an
LSUIElementapp..rightMouseDownreaches the panel'ssendEvent(left-clickalready does, so this is likely but unverified).
Flagging this explicitly rather than letting a reviewer assume it was
smoke-tested.