I was thinking I'd eventually need more than two states, and so hadn't 
considered a checkbox. Happily, today's problem only requires the two 
states, and so a little rework has yielded what looks to be a better 
solution. Thanks for the suggestion.<br><br><br><div class="gmail_quote">On Tue, Feb 21, 2012 at 10:53 AM, Matthew Flatt <span dir="ltr">&lt;<a href="mailto:mflatt@cs.utah.edu">mflatt@cs.utah.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The idea of `set-state-normal&#39; and `set-state-selected&#39; sounds like a<br>
`check-box%&#39; rather than a `button%&#39;.<br>
<br>
Otherwise, there&#39;s no way to change the background color of a `button%&#39;<br>
instance. Classes like `button%&#39; correspond to platform-specific GUI<br>
widgets that typically either don&#39;t support or strongly discourage the<br>
possibility of changing a button&#39;s background (because button colors<br>
are normally determined by a theme). You can create a `canvas%&#39; that<br>
draws a custom button image, in which case you have complete control<br>
over how the button looks and reacts, but there isn&#39;t much of an<br>
in-between level of customization in the current toolkit.<br>
<br>
At Tue, 21 Feb 2012 00:25:52 -0700, Kieron Hardy wrote:<br>
&gt; Hi all,<br>
&gt;<br>
&gt; How do I change the background color (and/or style of border etc.) of a GUI<br>
&gt; button? Given the code below, what should I put in the set-state-x methods<br>
&gt; to indicate a difference between a normal and selected button?<br>
&gt;<br>
&gt; Also any comments on program style and/or substance are appreciated (I<br>
&gt; apologize in advance if the layout offends).<br>
&gt;<br>
&gt; Cheers,<br>
&gt;<br>
&gt; Kieron.<br>
&gt;<br>
&gt; ****<br>
&gt;<br>
&gt; #lang racket/gui<br>
&gt;<br>
&gt; (define color-button%<br>
&gt;   (class button%<br>
&gt;     (inherit refresh)<br>
&gt;<br>
&gt;     (define toggle<br>
&gt;       (let ([f #f])<br>
&gt;         (lambda ()<br>
&gt;           (set! f (not f))<br>
&gt;           f<br>
&gt;           )<br>
&gt;         )<br>
&gt;       )<br>
&gt;<br>
&gt;     (define (set-state-normal)<br>
&gt;       (printf &quot;color-button%: set-state-normal:\n&quot;)<br>
&gt;       ; ??? ; set background color to normal<br>
&gt;       (refresh)<br>
&gt;       )<br>
&gt;<br>
&gt;     (define (set-state-selected)<br>
&gt;       (printf &quot;color-button%: set-state-selected:\n&quot;)<br>
&gt;       ; ??? ; set background color to red<br>
&gt;       (refresh)<br>
&gt;       )<br>
&gt;<br>
&gt;     (define click-callback<br>
&gt;       (lambda (button control-event)<br>
&gt;         (printf &quot;color-button%: click-callback:\n&quot;)<br>
&gt;         (if (toggle)<br>
&gt;           (set-state-selected)<br>
&gt;           (set-state-normal)<br>
&gt;           )<br>
&gt;         )<br>
&gt;       )<br>
&gt;<br>
&gt;     (super-new (callback click-callback))<br>
&gt;<br>
&gt;     )<br>
&gt;   )<br>
&gt;<br>
&gt; (define f (new frame%<br>
&gt;                [label &quot;Colored Button&quot;]<br>
&gt;                [min-width 100]<br>
&gt;                [min-height 200]<br>
&gt;                )<br>
&gt;   )<br>
&gt;<br>
&gt; (define b (new color-button%<br>
&gt;               [parent f]<br>
&gt;               [label &quot;push me&quot;]<br>
&gt;               )<br>
&gt;   )<br>
&gt;<br>
&gt; (send f show #t)<br>
&gt; ____________________<br>
&gt;   Racket Users list:<br>
&gt;   <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</blockquote></div><br>