Repository navigation
feat(keymap): Shortcut 可以绑定鼠标中键和侧键 - #87
Closed
xiaoyumuxi wants to merge 2 commits into
Closed
xiaoyumuxi wants to merge 2 commits into
xiaoyumuxi wants to merge 2 commits into
Conversation
A Chord may now name the middle button or a side button of a mouse (mouse_middle, mouse_back, mouse_forward) with modifiers, and FromPointer reads one from a press. ui.Shortcut and Box.Shortcut take these names: a page-wide one acts on a press anywhere in the page before the element under the pointer has it, and an element's own acts on a press on it or inside it, the innermost winning. The primary and secondary buttons are never a chord: they select, drag and open menus.
A container that names a place and has a hit of its own, such as a tab holding an icon and a close button, matched its Shortcut only for targets inside the place: a press on the tab itself, or the focus on it, fell through to the page-wide Shortcut. The entry now keeps the container's identity, and a target equal to it counts as on the element.
23 of 31 tasks
|
已被上游 vivaui#533 (2bff845) 取代,并在 #89 同步进 fork main。 |
16 of 19 tasks
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.
背景
Lithe 想做两件事(1lck/Lithe-IDEA#2554):在标签页上按鼠标中键关闭它;按鼠标侧键后退、前进。还想让用户在快捷键表里绑定带修饰键的中键和侧键(比如 Ctrl+中键)。之前
keymap.Chord只能表示键盘按键,ui.Shortcut也只响应按键事件,所以应用层没法用同一套快捷键机制处理鼠标按键。改动
1.
keymap:Chord 能表示中键和侧键(3a6db08d)Chord新增Button字段,名字是mouse_middle、mouse_back、mouse_forward,可以带修饰键(例如ctrl+mouse_middle)。Parse、Name、Label、Keycaps都支持。FromPointer,把一次鼠标按下转成 Chord。FromPointer遇到左右键返回ok=false。keymap/doc.go的包说明。2.
ui.Shortcut/Box.Shortcut响应鼠标按键(3a6db08d)Page新增pointerShortcutRoute,和按键的shortcutRoute对称;base/accessors.go补了对应的读取方法。3. 修复:带名字的容器,它自己的 Shortcut 要作用在容器本身(a8a479bc)
有些容器会命名一个区域,同时自己也有命中区。例如一个标签页,里面有图标和关闭按钮。以前这种容器的 Shortcut 只对区域里面的目标生效:按在标签页本身上,或者焦点在标签页本身上,都会落到页面级的 Shortcut。现在
shortcutEntry记下容器自己的 ID(own),目标等于这个 ID 时也算按在元素上。这个修复对按键 Shortcut 同样生效:焦点停在带名字的容器本身上时,以前容器的按键 Shortcut 不会触发,现在会触发。测试
keymap/chord_test.go:解析、序列化、标签和键帽的往返;FromPointer对左右键返回 false;FromPointer。ui/shortcut_test.go:TestShortcutActsOnMouseButtonsWhereThePressLands覆盖页面级和元素级的中键、侧键,最内层优先,以及容器本身、容器里的按钮两种落点(chip 用例:按在 chip 上关闭;按在 chip 里的按钮上,由 chip 的 Shortcut 处理,按钮不会被点击)。性能
在同一台机器上比较改动前后(
go test -bench):已知的既有失败(和本 PR 无关)
在 main 上运行全量检查时,下面这些本来就失败,本 PR 没有改动它们:
cmd/viva、components的TestDocCatalogCoversEveryComponent、internal/gallery的 OTP 测试(TestTypingInTheMiddleOfAnOTP,在 bbc1f4b 上也失败)、tools/docs、tools/visualparity。