[Cuis-dev] Button with icon

Juan Vuletich juan at cuis.st
Tue May 27 09:17:34 PDT 2025


On 5/26/2025 5:49 PM, Hilaire Fernandes via Cuis-dev wrote:
>
> Changing to use iconOnly: will be fine, but it fells like a strange 
> protocol to have both icon: and iconOnly:
>
> My believing you should not have both, and if icon only it should be 
> guess automatically by the button
>
> Le 26/05/2025 à 22:17, Juan Vuletich a écrit :
>> Your code is OK, but it (unsurprisingly) it breaks the other use 
>> case. I just pushed an update that integrates most of your code, but 
>> adds a new method #iconOnly: to specify the icon, and that nothing 
>> else should be drawn for this button. May I ask you to change your 
>> senders to this new selector?
> -- 
> http://mamot.fr/@drgeo

Please evaluate all the code below on a Workspace in an updated Cuis image.
- You want the first button, where only the icon is shown
- Other developers may want the second button, because they use it 
together with the third button, and want them to look similar.

The first button has icon and no button shape. The second has icon and 
button shape. The third has label and button shape. The fourth has only 
button shape. Someone may even want the fifth one.

The code below shows a possible way to do all this. If you don't like 
it, please post a similar example, covering all possibilities, in the 
style you prefer. Then we can choose.

Thanks,

button := PluggableButtonMorph model: 42 action: #startGame ::
         enableSelector: #notNil;
         iconOnly: Theme current playIcon;
         borderWidth: 2;
         borderColor: Color black;
         setBalloonText: 'Play the game';
         morphExtent: 64 asPoint.
button openInWorld; morphPosition: 80 at 80.

button := PluggableButtonMorph model: 42 action: #startGame ::
         enableSelector: #notNil;
         icon: Theme current playIcon;
         borderWidth: 2;
         borderColor: Color black;
         setBalloonText: 'Play the game';
         morphExtent: 64 asPoint.
button openInWorld; morphPosition: 160 at 80.

button := PluggableButtonMorph model: 42 action: #startGame ::
         enableSelector: #notNil;
         label: '>';
         borderWidth: 2;
         borderColor: Color black;
         setBalloonText: 'Play the game';
         morphExtent: 64 asPoint.
button openInWorld; morphPosition: 240 at 80.

button := PluggableButtonMorph model: 42 action: #startGame ::
         enableSelector: #notNil;
         borderWidth: 2;
         borderColor: Color black;
         setBalloonText: 'Play the game';
         morphExtent: 64 asPoint.
button openInWorld; morphPosition: 320 at 80.

button := PluggableButtonMorph model: 42 action: #startGame ::
         enableSelector: #notNil;
         label: 'lalalalallalalalalaa';
         icon: Theme current playIcon;
         borderWidth: 2;
         borderColor: Color black;
         setBalloonText: 'Play the game';
         morphExtent: 200 at 64.
button openInWorld; morphPosition: 400 at 80.

-- 
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250527/fedacdbb/attachment.htm>


More information about the Cuis-dev mailing list