0

I'm writing an extension that shows two items on a popup ("Hello" and "Goodbye").

What I want to do is, when the user click one of these items, insert the respective text.

For example: I'm on gedit and I want to insert "Hello". So I open the extension and then I click "Hello" and it appears on gedit.

Here's the current code:

this._menucontent = null;

this._mymenu = new PopupMenu.PopupMenuItem(this._menucontent, { reactive: true });

item = new PopupMenu.PopupMenuItem(_("Hello"));
this.menu.addMenuItem(item);
item = new PopupMenu.PopupMenuItem(_("Goodbye"));
this.menu.addMenuItem(item);

Could anybody help me?

user4815162342
  • 141,790
  • 18
  • 296
  • 355
user3474251
  • 209
  • 2
  • 12

1 Answers1

0

First you would need to connect to an emit signal of your clickable menuitems, in this case the 'activate' signal:

    item.connect('activate', _FunctionToCall);

Then in the Function you need to call some kind of 'paste' action to insert your text. The Gnome3 Extension 'Drop Down Terminal' has a function that pastes text from the clipboard so maybe a look at it's code will give you a hint:

github/dropdownterminal terminal.js

It is using gi.Gtk to interact with the Terminal Window.