-
24 Jul 2012 11:05 PM #1
Answered: Tap event on a toolbar
Answered: Tap event on a toolbar
I want a add a feature to my site where if a users taps on the top toolbar the contents of the page would scroll back to the top.
I can handle the scrolling. I just noticed that the toolbar does not have a tap event. Is there a way I can make it throw one?
-
Best Answer Posted by deliriousrhino
I solved this problem by placing a absolutely position button in my base class for all my views
{
xtype: 'button',
action: 'scrollToTop',
cls: 'scrollTopTopBtn',
top: 0,
left: 60,
width: Ext.Viewport.getSize().width - 120,
height: 43
}
Then I listened for the 'scrollToTop' action in a controller
-
25 Jul 2012 2:32 AM #2Sencha - Community Support Team
- Join Date
- May 2012
- Location
- Istanbul
- Posts
- 1,331
- Vote Rating
- 77
- Answers
- 124
Hi deliriousrhino,
You can do this to add item (like button) into your top toolbar, for example
Code:{ xtype : 'toolbar', docked: 'top', items:[{ text:'Return Top', handler:function(){ alert('Scrolling top'); } }] }sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
25 Jul 2012 2:49 AM #3
Thanks sword-it.
It see how it could be done in your example.
However I would much rather listen for an a event in a controller via controls that way I would not need to add the item and handle to every toolbar. Also I use now navigation views which add their own toolbars
-
25 Jul 2012 9:46 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
- Answers
- 3157
The buttons will fire the tap event so you can listen to them in the controller
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.
-
28 Jul 2012 11:06 PM #5
I solved this problem by placing a absolutely position button in my base class for all my views
{
xtype: 'button',
action: 'scrollToTop',
cls: 'scrollTopTopBtn',
top: 0,
left: 60,
width: Ext.Viewport.getSize().width - 120,
height: 43
}
Then I listened for the 'scrollToTop' action in a controller


Reply With Quote