Manage Left/Right click into panel menu

I present a simple and dirty solution for manage the left click and the right click event into a panel menu button of the gnome shell DE; all consosiste simply fill the menu with all the items of both the left than to the right menu, and intercept the type of event to hide the group of menu items on the left or instead to hiding the group of menu items on the right. this is the sample code:

const DoubleIndicatorSample_Indicator = new Lang.Class({
    Name: 'DoubleIndicatorSample.indicator',
    Extends: PanelMenu.SystemStatusButton,

    _init: function() {
        this.parent(null, "doubleindicatorsample-indicator")

        this.iteml1 = new PopupMenu.PopupMenuItem(_("Left Menu Item 1"));;
        this.iteml2 = new PopupMenu.PopupMenuItem(_("Left Menu Item 2"));;

        //add separetor menu PopupMenu.PopupSeparatorMenuItem());
        //add option menu entry
        this.imOptions = new PopupMenu.PopupMenuItem(_("Options"));;
        this.imOptions.connect('activate', Lang.bind(this, this._doExtensionPreferences));

        this.itemr1 = new PopupMenu.PopupMenuItem(_("Right Menu Item 1"));;
        this.itemr2 = new PopupMenu.PopupMenuItem(_("Right Menu Item 2"));;
        this.itemr3 = new PopupMenu.PopupMenuItem(_("Right Menu Item 3"));;
        this.itemr4 = new PopupMenu.PopupMenuItem(_("Right Menu Item 4"));;

    _onButtonPress: function(actor, event) {
        let button = event.get_button();
        if (button === 1) {
            Lib.TalkativeLog('Test18 > event indicator left click');

        } else if (button === 3) {
            Lib.TalkativeLog('Test18 > event indicator right click');
    _enableMenuLeft: function(){;;;

    _disableMenuLeft: function(){;;;
    _enableMenuRight: function(){;;;;

    _disableMenuRight: function(){;;;;

    _doExtensionPreferences: function() {
        Lib.TalkativeLog('Test18 > open preferences');

    destroy: function() {

that’s all.8y3



Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:


Stai commentando usando il tuo account Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...