Re: eventbox highlight



Allin Cottrell wrote:

I have a plain gtklabel which I would like to have "light up" on
mouse-over (as do the labels associated with checkboxes).  I have
tried sticking the label inside a gtkeventbox.  That by itself doesn't
do the trick.  Can anyone suggest how to do this?  Is it enough to set
some parameter on the eventbox, or do I need to attach a suitable
callback to "enter-notify-event" for the box?  Thanks.

As far as I know there aren't any simple parameters available to achieve
what you want. Your approach with putting a GtkEventbox around it is a
correct first step. You should indeed create an event handler which is
triggered when the mouse enters (or leaves respectively) the area in
question. The handler should then change the appearance of the label as
desired. I'm not sure which one is the right or easiest or working way
but spontaneously I have these three approaches in mind:

a) modifying the background color of the GtkLabel / GtkEventbox via
http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#gtk-widget-modify-bg

b) playing with styles of widgets as with
http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#gtk-widget-style-get,
though I haven't found the setter function yet  ;-)

c) handling the expose event and draw the label on your own. See
http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#GtkWidget-expose-event

If a) works it's certainly the simpliest way. I haven't tested any of
these yet. Please regard that a dumb GtkLabel with active hilighting
behaviour is likely to confuse users as they might expect further
functionality from it while there isn't any. However, since I like such
weird ideas I'm probably gonna try it out sometime by myself  ;-)



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