Skip to content

Selectable Text + Context Menu#1288

Draft
hojjatabdollahi wants to merge 7 commits into
pop-os:masterfrom
hojjatabdollahi:hojjat/select-popup
Draft

Selectable Text + Context Menu#1288
hojjatabdollahi wants to merge 7 commits into
pop-os:masterfrom
hojjatabdollahi:hojjat/select-popup

Conversation

@hojjatabdollahi

@hojjatabdollahi hojjatabdollahi commented May 20, 2026

Copy link
Copy Markdown
Contributor

The idea is that adding .selectable() to any Text should:

  • make the text selectable using mouse
  • user should be able to right click and choose select all/copy from a context menu
  • the text should become focusable and the user should be able to navigate to it, select using shift+arrow keys and copy using ctrl+c

Also all TextInput and TextEditor widgets should automatically have the context menu (copy/cut/paste/select all) too. The user shouldn't need to add any special code to their update() for any of the widgets.

I have achieved the goals above with this implementation.

  • test wayland popup
  • test overlay (resizing the window crashed in x11, but it's a pre-existing issue)
  • merge requirements into Iced: HasSelectableText trait iced#339
  • The selected_text_fill color is not being set correctly for Text
  • Implement the logic for the correct position for the context menu (right now it's always to the bottom right, causing it to clip in x11 and stick out needlessly on wayland)
  • The wayland popup context menu doesn't highlight the item on hover correctly, or consistently. I worry it's a deeper issue.

Still working on it. But I thought this is good enough in case there are any feedback.

The diff is kinda big, but two large files are text and text_editor which are just wrappers.


  • I have disclosed use of any AI generated code in my commit messages.
    • If you are using an LLM, and do not fully understand the changes it is making to the code base, do not create a PR.
    • In our experience, AI generated code often results in overly complex code that lacks enough context for a proper fix or feature inclusion. This results in considerably longer code reviews. Due to this, AI authored or partially authored PRs may be closed without comment.
  • I understand these changes in full and will be able to respond to review comments.
  • My change is accurately described in the commit message.
  • My contribution is tested and working as described.
  • I have read the Developer Certificate of Origin and certify my contribution under its conditions.

@hojjatabdollahi hojjatabdollahi changed the title Hojjat/select popup Selectable Text + Context Menu May 20, 2026
@mmstick

mmstick commented May 20, 2026

Copy link
Copy Markdown
Member

Merged the changes in iced and updated libcosmic.

@hojjatabdollahi hojjatabdollahi force-pushed the hojjat/select-popup branch 3 times, most recently from 642ecb1 to c826d41 Compare May 20, 2026 16:29
@hojjatabdollahi

Copy link
Copy Markdown
Contributor Author

Still working on this. Not sure why I can't get the wayland popup context menu items to react to mouse hover consistently. I'll figure it out.

@wash2

wash2 commented May 21, 2026

Copy link
Copy Markdown
Contributor

I don't love the way that the context menu is created, but I understand that it makes this more of a drop-in change and support for the context menu less cumbersome in general. This creates the popup directly through sctk, but I wonder if it could use the surface Action instead, and maybe the simple_popup helper.

That aside, for set_current_window_id, we set the window id in the view method, but would it make sense to set this in response to a window focus event instead?

As for whether it is worth it to try to keep the best effort backward compatibility, I think that it generally is, but we could try to time this along with the changes for theme-v2, which also brings some slightly breaking changes.

@hojjatabdollahi

Copy link
Copy Markdown
Contributor Author

I'm working on another approach without needing to go to sctk directly. I'll push that soon.
It took me 2 days to figure out why the menu items aren't highlighting in wayland popups.
I'll have something soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants