PDA

View Full Version : stateful toggled button in a toolbar



Kotolom
6 Feb 2013, 4:47 AM
I'm trying to safe the state of toggled buttons in a toolbar.
It doesn't function. No matter whether I'm adding "stateful:true" to the button or to toolbar.

Is it possible at all?

Kotolom
22 Feb 2013, 2:15 AM
sure it is possible. Here is a sample for stateful button


Ext.define('ui.menus.toolbar.StatefulButton', {
extend: 'Ext.button.Button',
alternateClassName: 'StatefulButton',
alias: 'widget.StatefulButton',

stateEvents: ['press'],
stateId: 'statefulButton',
enableToggle: true,
stateful: true,

getState: function() {
return { pressed: this.pressed };
},

applyState: function(state) {
this.toggle(state.pressed);
},

listeners: {
toggle: function(self, pressed, eOpts) {
this.fireEvent('press');
}
}

});