Re: Change button color in button-press-event

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

 



I do have resource file with the following style:

style "ButtonStyle"
{
    font_name = "Sans 13"
    bg[SELECTED] = {0, 1.0, 0}
    bg[ACTIVE] = {0, 0, 1.0}
    bg[INSENSITIVE] = {0.5, 0.5, 0.5}
    fg[INSENSITIVE] = {0.5, 0.5, 0.5}
}

However that does not seem to work.

This is for an embedded device with touch screen, no mouse.
If I send activate signal from my code to a button, it turns blue and then back to its initial color, as expected. When I press the button with my finger, I do get click event, but button color never changes. I noticed that most of the time PRESS is received only when I remove my finger from the button.

Thank you,

D.



Quoting Robert Pearce <rob@xxxxxxxxxxxxxxxxxxxx>:

Hi gtk@xxxxxxxxxx,

On Sat, 24 Apr 2010 09:49:37 -0400 you wrote:

When a button is pressed, I want to change its color to blue, and when
it is released to restore its original color.

When you say "pressed", you mean active? I think you need to look up the documentation on styles and themes.

The code I use is shown below.
I do get BUTTON PRESS and BUTTON RELEASE messages, but the button
color does not change.

<snip>
     gtk_widget_modify_bg(widget, GTK_STATE_PRELIGHT, &color);
     gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &color);

So if you want to affect the appearance of the button while "pressed", which is called "ACTIVE", then why are you setting its colour in the "NORMAL" and "PRELIGHT" states?

If I understand your intentions right, I don't think you need signal handlers or call-backs. Just set the widget's "ACTIVE" background colour and GTK will do the rest.


Rob
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list



_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux