Re: Enter-event and leave-event



You've discovered the fun of the input shape! The simple answer is to replace:

    Main.uiGroup.add_actor(box);

with:

    Main.layoutManager.addChrome(box);

I'll follow up with a more thorough explanation to the list in a bit. Hopefully for 3.10 we can fix this better.


On Thu, Mar 21, 2013 at 12:50 PM, Vadim <vadim dbfin com> wrote:
Hi, everyone,

A list new-comer's question.

Here's a very simple "extension" to illustrate the problem:

const Shell = imports.gi.Shell;
const St = imports.gi.St;

const Main = imports.ui.main;

function init () {
}

function enable () {
    let (box = new St.BoxLayout({   reactive: true,
                                    width: 50,
                                    height: 50,
                                    x:    Main.layoutManager.primaryMonitor.x + 50,
                                    y:    Main.layoutManager.primaryMonitor.y
                                        + (Main.panel.actor.get_height() >> 1) })) {
        global.stage._boxTest = box;
        Main.uiGroup.add_actor(box);
        box.set_style('background: rgba(0, 0, 0, 0.7)');
        box.show();
        box.raise_top(); // let's try everything
        box.connect('enter-event', function () { global.set_cursor(Shell.Cursor.POINTING_HAND); });
        box.connect('leave-event', function () { global.unset_cursor(); });
    } // let (box)
}

function disable() {
    if (global.stage._boxTest) {
        global.stage._boxTest.destroy();
        global.stage._boxTest = null;
    }
}
 
What it does is just create a simple fixed sized StBoxLayout and put it so that it covers half panel vertically. So, the box looks like this:

---------------------------------------------------

Panel       -----------------------
           | Box           
Area A |
---------------------------------------------------
           |                Area B |
            -----------------------


Then all I want is to change cursor when the mouse pointer is over the box.

What happens: when the pointer moves to Area A, the cursor indeed changes to "hand". But when it moves to Area B (whether from outside or from Area A) the cursor changes back to normal as if Area B was not a part of the box at all.
In fact, in Area B the cursor changes depending on whatever is below the box. In other words, it "sees through the box" and behaves as if there were no box at all.

Somehow, when the box is over the main panel, Clutter delivers the signal/event to the box, otherwise it does not, and moreover if the pointer moves from Area A to Area B the box receives the 'leave-event' signal!

Also, a note: if I change Main.uiGroup to something else, like its parent global.stage, it does not change anything. And, of course, changing the box's opacity to 1.0 does not help either. It is set to 0.7 just to see what is below it. Another observation is that if I open, for example, LookingGlass, then the whole box works as expected.

It seems to me that I am missing just a little detail to make it work. So, my question is simple enough: what is missing in the code above.

Thanks in advance for your help,
Vadim.


_______________________________________________
gnome-shell-list mailing list
gnome-shell-list gnome org
https://mail.gnome.org/mailman/listinfo/gnome-shell-list




--
  Jasper


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]