<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    On 6/6/2024 6:24 PM, Mark Volkmann via Cuis-dev wrote:
    <blockquote
cite="mid:CAFfRWnUh9vbuT4a4oxgHTtq61ypqdDA6ufbpAA4T4OaJ1jKp4Q@mail.gmail.com"
      type="cite">
      <div dir="ltr">I'm trying to learn how to create a button and have
        something happen when the button is clicked. I've done a lot of
        Googling for this, but haven't found the solution.
        <div>Here is what I tried based on example code I found:</div>
        <div><br>
        </div>
        <div><font face="monospace">s1 := Switch new.<br>
            btn := PluggableButtonMorph model: s1 action: [Transcript
            show: 'got click'] label: 'Click Me'.<br>
            btn color: (Color blue); enableLabelColorWith: (Color
            yellow).<br>
            btn openInWorld.</font></div>
        <div><br>
        </div>
        <div>Perhaps I don't really need to create a `Switch`. I hope
          I don't, but it seems all the creation methods for
          `PluggableButtonMorph` require that.</div>
        <div>I'm not sure if `PluggableButtonMorph` is the class I
          should be using.</div>
        <div>This code does create and render a button, but it does not
          set the label color to yellow and I get the following error
          when I click the button:</div>
        <div><br>
        </div>
        <div><font face="monospace">BlockClosure(Object)>>doesNotUnderstand:
            #asPlainString</font></div>
        <div>
          <div><br>
          </div>
          <span class="gmail_signature_prefix">-- </span><br>
          <div dir="ltr" class="gmail_signature"
            data-smartmail="gmail_signature">
            <div dir="ltr">
              <div>
                <div dir="ltr">
                  <div>
                    <div dir="ltr">
                      <div dir="ltr">
                        <div><font face="arial, helvetica, sans-serif">R.
                            Mark Volkmann</font></div>
                        <div><span style="font-size: 12.8px;"><font
                              face="arial, helvetica, sans-serif">Object
                              Computing, Inc.</font></span></div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Hi Mark,<br>
    <br>
    You're almost there. This does work:<br>
    <br>
    s1 := Switch new.<br>
    btn := PluggableButtonMorph model: [Transcript show: 'got click']
    action: #value label: 'Click Me'.<br>
    btn color: (Color blue); enableLabelColorWith: (Color yellow).<br>
    btn openInWorld.<br>
    <br>
    As you see, the action is a symbol, a message to be sent to some
    object. The model is the object that will get that message. Sending
    #value to a code block works.<br>
    <br>
    Happy Hacking!<br>
    <pre class="moz-signature" cols="72">-- 
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich</pre>
  </body>
</html>