Is it possible to disable menu focus?

I’m trying to copy and paste data from a Gtk::Entry through a Menu item, but after selecting the data the focus is changed to the Menu and I can’t use Clipboard to capture the data.
Is there a way to not focus on the menu to access menu items?


Note: I am porting the app to the Gtk4 version

I’m not sure about the sequence of operations.

You select the contents of the entry, then open a menu and… What? Try to copy using Ctrl+C? Or paste into the menu?

Can’t you copy the contents before opening the menu?

Is this a programmatic issue?

Yes, I can copy and paste from the keyboard without having to go to the menu.
But since I’m porting the app, I wanted to leave these features as they were.

I still don’t understand what kind of feature you’re describing, or how the port is related to them.

Can you explain in detail what is the sequence of actions you’re performing?

I select a piece of data in Entry, then click on the Edit menu and the Copy item. But clicking on Edit takes the focus off the data in the Entry and stays in the Edit Menu.
In the old version of the program, the focus was on the Entry data

Thanks, I finally understand.

No, the focus is moved to the menu in order to allow keyboard navigation: it’s the expected behaviour essentially everywhere, and it’s a fundamental accessibility feature.

The focus change to a different window does not clear the selection, though; that means that the Copy menu item can still cause the entry to copy its contents to the clipboard: you need to access the entry from the Copy menu item activation—the menu item’s “activate” signal handler, or the action activation if you’re using GMenu/GAction—and get the selected text.

I understood.
Thank you Ebassi.

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.