On Tue, 2006-03-07 at 23:48 +0100, Uwe Kubosch wrote:
> > For most applets you'll don't need this. If you only want to respond to
> > left-clicks just enable the button-press-event in you label.
> > If you think that you'll need a button, pleas explain what you want to
> > do.
> I would like to have my applet look and behave similarly to the Clock
> applet. When you let your mouse pointer hover over the Clock applet,
> the applet is outlined and you can press it like a button. I you
> right-click it, you get the context menu.
> I would like the same for my applet. Is it possible? If so, how?
Sure, that's easy.
One way you can do this:
Put your label into a frame and the frame into a eventbox. Connect the
eventbox to the button-press-, the enter- and the leave-event.
You need the eventbox, cause the label and the frame are both
no-window-widgets. That means they don't own an Gdk::Window but draw on
there parent window and as a side effect can't recive events.
Initialize the frame with ShadowType = None. The callback for your
enter-event changes the ShadowType to In and the leave-event back to
In your button-press-event handler you have to check which button is
pressed. If its the left one popup your window, for the right one you
have to foreward the event to the original handler, else the menu would