-
28 Aug 2012 5:12 AM #1
Unanswered: Need to add touchstart and touchend event for button?
Unanswered: Need to add touchstart and touchend event for button?
Could you please tell me how to add touchstart event for a button in sencha touch 1.1.
Ref:
In the thread http://www.sencha.com/forum/showthre...896#post878896 it says that add the event in element.
For me, element attribute showing as undefined for a button, in sencha 1.1 docs element definition for button is also not available.
Could you please tell me how to use this ?
-
30 Aug 2012 4:06 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3102
That thread is in the ST2 forums and things don't work the same. Here is one way you can do it but you don't really have access to the button instance there:
I would extend Button to do this:Code:new Ext.Button({ text : 'Test', listeners : { el : { touchstart : function () { console.log('touch start'); console.log(this); //of element }, touchend : function() { console.log('touch end'); console.log(this); //of element } } } });
And then you have a touchstart and touchend event on the component:Code:Ext.ns('Ux'); Ux.Button = Ext.extend(Ext.Button, { initEvents : function () { var me = this; me.mon(me.el, { scope : me, touchstart : me.onTouchStart, touchend : me.onTouchEnd }); }, onTouchStart : function (e) { this.fireEvent('touchstart', this, e); }, onTouchEnd : function (e) { this.fireEvent('touchend', this, e); } }); Ext.reg('ux-button', Ux.Button);
Code:new Ux.Button({ text : 'Test', listeners : { touchstart : function (btn, e) { console.log('touch start'); console.log(this); //of button }, touchend : function(btn, e) { console.log('touch end'); console.log(this); //of 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.


Reply With Quote