<div dir="ltr">Thanks so much! It seems like I should want a simpler way to create basic buttons. I added this class method to `PluggableButtonMorph` which is working fine. Is there anything bad about this approach or does a method similar to this already exist?<div><br></div><div><font face="monospace">label: aString onClick: aBlock<br> ^PluggableButtonMorph model: aBlock action: #value label: aString.</font><br></div><div><br></div><div>I can use this as follows:</div><div><br></div><div><font face="monospace">b := PluggableButtonMorph label: 'Test' onClick: ['got click' print].<br>b openInWorld.</font><br></div><div><font face="monospace"><br></font></div><div><font face="arial, sans-serif">What is the significance of a morph being "pluggable"?</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">I can change the background color of a button, but I haven't figured out how to change the text color.</font></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 6, 2024 at 5:04 PM Juan Vuletich <<a href="mailto:juan@cuis.st">juan@cuis.st</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><u></u>
<div bgcolor="#ffffff">
On 6/6/2024 6:24 PM, Mark Volkmann via Cuis-dev wrote:
<blockquote 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">
<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 cols="72">--
Juan Vuletich
<a href="http://cuis.st" target="_blank">cuis.st</a>
<a href="http://github.com/jvuletich" target="_blank">github.com/jvuletich</a>
<a href="http://researchgate.net/profile/Juan-Vuletich" target="_blank">researchgate.net/profile/Juan-Vuletich</a>
<a href="http://independent.academia.edu/JuanVuletich" target="_blank">independent.academia.edu/JuanVuletich</a>
<a href="http://patents.justia.com/inventor/juan-manuel-vuletich" target="_blank">patents.justia.com/inventor/juan-manuel-vuletich</a>
<a href="http://linkedin.com/in/juan-vuletich-75611b3" target="_blank">linkedin.com/in/juan-vuletich-75611b3</a>
<a href="http://twitter.com/JuanVuletich" target="_blank">twitter.com/JuanVuletich</a></pre>
</div>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="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>