-
26 Apr 2012 12:17 PM #1
Unanswered: depressed button
Unanswered: depressed button
what is the recommend way to show a single button that a user can press where the button will stay depressed until user taps it again? I don't want the look of the toggle field and i will only ever have a single button. Thoughts?
Thanks
John
-
28 Apr 2012 4:21 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
- Answers
- 3156
I simply add or remove the pressedCls CSS class to the button.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
1 May 2012 11:29 AM #3
in the tap event of the button i'm setting its pressed state like so but it's not changing. thoughts?
Code:button.setCls('x-button-pressing');
-
2 May 2012 4:05 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
- Answers
- 3156
Code:button.addCls(buttun.getPressedCls());
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
2 May 2012 10:04 AM #5
no joy. if i set the buttons cls in its config (vs programmatically) it shows the button depressed as it expected. i'll keep playing around with it.
-
2 May 2012 10:36 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
- Answers
- 3156
It works. Here is a full example for you
Code:new Ext.Container({ fullscreen : true, items : [ { xtype : 'button', text : 'Test', pressed : false, handler : function(button) { var pressedCls = button.getPressedCls(), isPressed = button.pressed; button[isPressed ? 'removeCls' : 'addCls'](pressedCls); button.pressed = !button.pressed; } } ] });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
31 May 2012 4:27 PM #7
You can use a segmented button.
You can use a segmented button.
The code above didn't work for me, but a neat and easy way to do it is to make one segmented button.\
THIS works.Code:new Ext.SegmentedButton({ allowMultiple: false, items: [ { pressed : false, text : 'Test' }] });


Reply With Quote