Opened 15 years ago

Closed 15 years ago

#1657 closed enhancement (wontfix)

Button widget to provide better support for icons

Reported by: [email protected] Owned by: Douglas Hays
Priority: low Milestone: 0.9
Component: Widgets Version: 0.3
Keywords: button icon caption widget Cc:
Blocked By: Blocking:


Currently, when using the button widget, if you want to add an icon to the button, you have to declare in markup:

<button dojoType="dojo:Button" dojoAttachPoint="dapMyButton" dojoAttachEvent="onClick:doStuff">

<img src="../images/stuff.gif" /> <span style="font-size:x-small; color: black">Do Stuff</span>


Would it be better to have the icon and caption defined as an attribute in the button element, e.g.

<button dojoType="dojo:Button" dojoAttachPoint="dapACSPResyncButton" dojoAttachEvent="onClick:doStuff" dojoIcon="../images/stuff.gif" dojoCaption="Do Stuff">


Currently, if you call setCaption, you have to pass in markup if you want the icon to remain in the button div because the code does:

setCaption: function(content){ 

This mixing of view and control is not too pretty, and when evaluating button captions means you have to have code such as:

if( this.myButton.caption == "<img src='../images/stuff.gif' /><span style='font-size:x-small; color: black'>Do Stuff</span>" )

Could we treat the icon and caption as properties on the button, e.g.

setCaption: function(content){ 

setIcon: function(content){ 

Maybe, this is another 'class' of button, e.g. IconButton? so that the base Button widget can remain as a simple container that you can put markup into?

Change History (3)

comment:1 Changed 15 years ago by dylan

Milestone: 0.5

comment:2 Changed 15 years ago by Douglas Hays

Owner: changed from bill to Douglas Hays

comment:3 Changed 15 years ago by Douglas Hays

Priority: normallow
Resolution: wontfix
severity: normalminor
Status: newclosed

I can see a limited need for a subclass of Button that just replaces the text w/o affecting the icon - but the current Button widget is intended to be the core base class - I would suggest that if you create the subclass to contribute it back to the community widget repository that is being created for 0.9. The current setCaption was intended for iconless buttons since usually the icons are related to the text and they shouldn't get out-of-sync.

Note: See TracTickets for help on using tickets.