Repository navigation
Buttons:SegmentedControl 新增 on_context,告诉调用方右键点在哪一段 - #11
Merged
Raiden-MeixElysia merged 1 commit intoNov 2, 2026
Merged
Conversation
… lands on, for ELYTerminal's Files tab; the press stops on the segment, so its focus never moves Co-Authored-By: Claude Opus 5.5 <[email protected]>
4 of 6 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.
这是 #10 在 main 上的版本:改动相同,移植到
crates/ely-core,另外补了 API 快照和 CHANGELOG。SegmentedControl新增了on_context(value, point, window, cx):右键按在某一段上时,把这一段的值和指针位置交给调用方。写法和已有的Tabs::on_context、Tree::on_context保持一致。起因是 ELYTerminal:右栏顶部的 Git/文件 切换用的就是
SegmentedControl,我想做到“右键文件那一段,展开一个在指定文件夹新建会话的操作栏”。原组件只告诉外部“左键选中了哪一段”,没法知道右键点在哪,ELYTerminal 只能自己重画一个控件,丢掉了滑块动画和阴影。有了这个接口,就能继续用原组件。处理器放在每一段自身上,并在那里拦住这次按下。原因是 gpui 在任意鼠标键按下时都会把焦点交给可聚焦的元素,而且子元素先于父元素执行;如果放在外层,等它收到事件时,焦点已经被这一段抢走了,键盘输入也会跟着跑掉。
没有新的绘制,控件外观和原来一样。
scripts/check.sh通过:在 Windows 上跑了 fmt、clippy(-D warnings)和库测试,见下文;GPUI Kit 兼容、wasm 和 stories 这几步没跑在 Windows 11(MSVC)上测过:
elyterminal-0.1.1分支:cargo fmt --check、cargo clippy --all-targets --features test-support -- -D warnings通过;cargo test --lib --features test-support2156 项通过。新增测试buttons::tests::a_right_press_names_its_segment_and_keeps_the_focus。main分支:cargo fmt --all --check通过;cargo clippy -p ely-core --all-targets --all-features -- -D warnings通过,cargo test -p ely-core --lib --all-features579 项通过。我本机是 Rust 1.95,而工作区要求 1.98,所以这两项加了--ignore-rust-version。prevent_default和stop_propagation去掉,新测试会失败,报“focus stays put”。api/ely-core.txt里那一行是我照Tabs::on_context的格式手写的。scripts/api.py --write要在 Linux 上跑,我没跑,留给 CI 的api任务检查。CHANGELOG.md的 Unreleased 下加了一条。🤖 Generated with Claude Code