Results 1 to 7 of 7

Thread: On tab icon tap

  1. #1
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    66
    Answers
    1
    Vote Rating
    1
      0  

    Default Answered: On tab icon tap

    Something I have found incredibly difficult is to listen for tab icon taps in a controller. I have tried to the following selectors and more

    Controller:
    Code:
    control: {
                'mytab':{
                    tap:'onTabTap'
                },
                'mytab button[action=myHomeButton]':{
                    tap:'onTabTap'
                },
    
    
            }

    In the end I went for the actual tab change
    Code:
    'myhome':{
                    activate:'onTabTap'
                }

    My view:
    Code:
    Ext.define("BibleVerse.view.Main", {
        extend: 'Ext.tab.Panel',
        requires: ['Ext.TitleBar'],
        xtype:'mytab',
        
        config: {
            tabBarPosition: 'bottom',
            items: [{
                xtype:'myhome',
                action:'myHomeButton'
            },{
                xtype:'mysettings'
            }]
            
        }
    });
    Any ideas?

  2. Try this selector:

    Code:
    mytab tab
    The tab panel has a child tab bar and the tab bar has child tabs.

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,411
    Answers
    3898
    Vote Rating
    1290
      0  

    Default

    Try this selector:

    Code:
    mytab tab
    The tab panel has a child tab bar and the tab bar has child tabs.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    66
    Answers
    1
    Vote Rating
    1
      0  

    Default

    Quote Originally Posted by mitchellsimoens View Post
    Try this selector:

    Code:
    mytab tab
    The tab panel has a child tab bar and the tab bar has child tabs.
    Thanks for your response

    Still no luck

    Code:
    'mytab tab':{
                    tap:function(){alert('help')}
                }

    Update: sorry - my mistake didnt upload properly.. Thanks for that! Worked like a treat

  5. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,411
    Answers
    3898
    Vote Rating
    1290
      0  

    Default

    Just saw your update. Prepared a simple test case, maybe it will help others:

    Code:
    Ext.define('Test.controller.Main', {
        extend : 'Ext.app.Controller',
    
        config : {
            control : {
                'tabpanel tab' : {
                    tap : 'onTabTap'
                }
            }
        },
    
        onTabTap : function() {
            console.log('tap');
        }
    });
    
    Ext.application({
        name : 'Test',
    
        controllers : [ 'Main' ],
    
        launch : function () {
    
            new Ext.tab.Panel({
                fullscreen : true,
                items      : [
                    {
                        title : 'One'
                    },
                    {
                        title : 'Two'
                    }
                ]
            });
    
        }
    });
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

    When posting code, please use BBCode's CODE tags.

  6. #5
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    66
    Answers
    1
    Vote Rating
    1
      0  

    Default

    Thanks for that! I'm sure it will

  7. #6
    Sencha User
    Join Date
    Apr 2012
    Posts
    70
    Vote Rating
    0
      0  

    Default

    hi Mitchell,

    As per your code whenever i click on any Tab One or Two "tap" is printed on console, but I want it to recognize the tabs tapped. i.e. I should be able to distinguished if tab one or Two is pressed?

    Thanks & Regards
    Mukesh pandey

  8. #7
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,411
    Answers
    3898
    Vote Rating
    1290
      0  

    Default

    The tab instance is the first argument in the onTabTap method. Or you can change the control statement to be a different selector.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

    When posting code, please use BBCode's CODE tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •