-
23 Mar 2007 2:32 PM #1
Toggle button: change button icon when pressed?
Toggle button: change button icon when pressed?
I have a toolbar button with toggling enabled:
This works OK, but I want to have a different icon when the button is in the pressed state. I tried to do the CSS the same way as for disabled buttons:Code:tb.addButton({ text: '', tooltip: 'Enable filter', cls: 'x-btn-icon filter-btn', enableToggle: true, toggleHandler: this.toggleFilter, scope: this}));
This does not work; the icon doesn't change.Code:.filter-btn .x-btn-text { background-image: url('../images/filter.gif'); } .x-item-disabled .filter-btn .x-btn-text { background-image: url('../images/filter-cold.gif'); } .x-btn-pressed .filter-btn .x-btn-text { background-image: url('../images/filter-on.gif'); }
I watched the button in Firebug as the button was toggled, and saw that .x-btn-pressed was added to the button table element when in pressed state, where .x-item-disabled is added to the td element that is the parent of the table element. I tried a variety of CSS chains for the pressed state, without success.
So, is there any way to have a "pressed" icon in a way similar to how we can have a "disabled" icon?David Badke
Humanities Computing and Media Centre
University of Victoria, BC, Canada
-
23 Mar 2007 3:50 PM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Forest Grove, OR
- Posts
- 1,038
- Vote Rating
- 0
Try:
The difference is there's no space between the .x-btn-pressed and .filter-btn classes. The reason for that is that these are classes applied to the same element so they must be chained together like this. Essentially it means, apply these style definitions to all elements with a class of .x-btn-text that are descendants of all elements that have both the .x-btn-pressed class and the .filter-btn class applied.Code:.x-btn-pressed.filter-btn .x-btn-text { background-image: url('../images/filter-on.gif'); }Jeff Howden
Ext JS - Support Team Volunteer
jeff@extjs.com
Any and all code samples that are authored by me and posted on the Ext forums or website are hereby released into the public domain and I release anyone or entity of liability by using said code samples unless explicitly stated otherwise.
Opinions are mine and not necessarily endorsed by Ext, LLC. Please do not contact me directly for assistance unless requested by me.
-
26 Mar 2007 7:14 AM #3
Thanks. That works!
David Badke
Humanities Computing and Media Centre
University of Victoria, BC, Canada
Similar Threads
-
Ext.BasicDialog , button with icon issue
By nseb in forum Ext 2.x: Help & DiscussionReplies: 6Last Post: 8 Apr 2011, 9:13 AM -
change treeNodes Icon after tree render??
By omid in forum Ext 2.x: Help & DiscussionReplies: 3Last Post: 15 Dec 2009, 8:32 AM -
Button of Confirm
By francescotorres in forum Community DiscussionReplies: 0Last Post: 16 Mar 2007, 6:46 PM -
jsb files on svn missing new button.js and button.css refs
By jarrod in forum Ext 1.x: BugsReplies: 2Last Post: 11 Dec 2006, 5:38 AM


Reply With Quote
