* @cfg {String} theme default
* @cfg {Boolean} inverse
* @cfg {Boolean} toggle is it a slidy toggle button
- * @cfg {String} ontext text for on toggle state
- * @cfg {String} offtext text for off toggle state
- * @cfg {Boolean} defaulton
- * @cfg {Boolean} preventDefault default true
+ * @cfg {Boolean} pressed (true|false) default null - if the button ahs active state
+ * @cfg {String} ontext text for on slidy toggle state
+ * @cfg {String} offtext text for off slidy toggle state
+ * @cfg {Boolean} preventDefault default true (stop click event triggering the URL if it's a link.)
* @cfg {Boolean} removeClass remove the standard class..
* @cfg {String} target target for a href. (_self|_blank|_parent|_top| other)
*
/**
* @event click
* When a butotn is pressed
- * @param {Roo.bootstrap.Button} this
+ * @param {Roo.bootstrap.Button} btn
* @param {Roo.EventObject} e
*/
"click" : true,
/**
* @event toggle
* After the button has been toggles
+ * @param {Roo.bootstrap.Button} btn
* @param {Roo.EventObject} e
* @param {boolean} pressed (also available as button.pressed)
*/
}
- if (this.active) {
+ if (this.active || this.pressed === true) {
cfg.cls += ' active';
}
if(this.preventDefault){
e.preventDefault();
}
+
if (this.pressed === true || this.pressed === false) {
this.pressed = !this.pressed;
this.el[this.pressed ? 'addClass' : 'removeClass']('active');
setActive : function(v) {
this.el[v ? 'addClass' : 'removeClass']('active');
+ this.pressed = v;
},
/**
* toggles the current active state
},
setWeight : function(str)
{
- this.el.removeClass(this.weightClass);
+ this.el.removeClass(this.weightClass);
this.el.addClass('btn-' + str);
}