What about connecting two signals to your button widget: pressed and released<div><br></div><div>In the function for "pressed" change the background colour to blue.</div><div><br></div><div>In the function for "released" change the background colour back to normal.</div>
<div><br></div><div><a href="http://library.gnome.org/devel/gtk/stable/GtkButton.html#GtkButton.signals">http://library.gnome.org/devel/gtk/stable/GtkButton.html#GtkButton.signals</a></div><div><br></div><div>I think this should do what you want, though I don't know if it is the optimal way.</div>
<div><br></div><div>Andrew<br><br><div class="gmail_quote">2008/11/25 Yao Wang <span dir="ltr"><<a href="mailto:yaowang.bupt@gmail.com">yaowang.bupt@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi, Dave,<br><br>Thanks for your advice.<br><br>However, my objective is to set two different colors for two different buttons. That is to say, for button A, when it is pressed, the color should be red; while for button B, in this case, the color should be green. <br>
<br>Thus I do not think the GTK+ theme can solve this problem. <br>Is there any other possible solutions?<br><br>Thanks in advance.<div class="Ih2E3d"><br><br><div class="gmail_quote">On Tue, Nov 25, 2008 at 10:23 AM, Dave Neary <span dir="ltr"><<a href="mailto:dneary@maemo.org" target="_blank">dneary@maemo.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">Hi Yao,<br>
<div><br>
Yao Wang wrote:<br>
> The default color when I pressed down the button is blue. I want<br>
> to change the background color of button when it is pressed and recover<br>
> its origin background color when it is released.<br>
<br>
</div>The default colour for when the button is pressed is set by the GTK+<br>
theme. I'd suggest changing the theme so that all buttons, when pressed,<br>
will be red. It's in general not a good idea to hack applications with<br>
hard-coded widget colours, and it's generally encouraged to write<br>
applications which are consistent with the rest of the environment.<br>
<br>
Hope this helps!<br>
Dave.<br>
<font color="#888888"><br>
--<br>
<a href="http://maemo.org" target="_blank">maemo.org</a> docsmaster<br>
Email: <a href="mailto:dneary@maemo.org" target="_blank">dneary@maemo.org</a><br>
Jabber: <a href="mailto:bolsh@jabber.org" target="_blank">bolsh@jabber.org</a><br>
<br>
</font></blockquote></div><br><br clear="all"><br></div><div><div></div><div class="Wj3C7c">-- <br> Sincerely yours, <br><br>Yao Wang<br><br>Mobile Life Lab<br>Beijing University of Posts & Telecommunications<br>
</div></div><br>_______________________________________________<br>
maemo-developers mailing list<br>
<a href="mailto:maemo-developers@maemo.org">maemo-developers@maemo.org</a><br>
<a href="https://lists.maemo.org/mailman/listinfo/maemo-developers" target="_blank">https://lists.maemo.org/mailman/listinfo/maemo-developers</a><br>
<br></blockquote></div><br></div>