Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: add dropdown menu to panel tool

  1. #11
    Sencha User Misiu's Avatar
    Join Date
    Jun 2012
    Location
    Poland
    Posts
    260

    Default

    Thank You so much for help, I tried calling callParent but with different parameters.
    You wrote earlier that I must pass arguments I didn't thought that I must literally pass arguments as parameter
    Now it works almost perfect.

    One more thing-is my onDestroy correct?
    PHP Code:
        onDestroy: function() {
            var 
    me this;
            
    Ext.destroyMembers(me'toolMenu');
            
    me.callParent();
        } 

  2. #12
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791

    Default

    There's not much point using me = this for two references but from a destruction perspective it looks fine.

  3. #13
    Sencha User Misiu's Avatar
    Join Date
    Jun 2012
    Location
    Poland
    Posts
    260

    Default

    fixed
    thanks for help, as You suggested I'll post other questions in new threads.

  4. #14
    Sencha Premium Member
    Join Date
    Mar 2010
    Posts
    10

    Default Issue with callParent in ExtJS 5.0

    Code has stopped working in ExtJS 5.0.
    It did not allow to override onClick method giving following error. Please help.

    Uncaught Error: ExtMVC.view.app.ToolMenu: Public method "onClick" conflicts with private framework method declared by Ext.panel.Tool



  5. #15
    Sencha Premium Member
    Join Date
    Mar 2010
    Posts
    10

    Default Issue Fixed.

    I was able to make it work by:

    1. Instead of overriding onClick, I used click and destroy listeners.
    2. Copy the same code in click listener but instead of callParent code, copy the actual onClick code from source code of Ext.panel.Tool.onClick method. (as Misiu did initially)

  6. #16
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791

    Default

    Surely you just need to move it to the privates block?

    http://docs.sencha.com/extjs/5.0.0/w...rivate_Methods

  7. #17
    Sencha Premium Member
    Join Date
    Mar 2010
    Posts
    10

    Default

    Thanks skirtle, adding privates block is the proper way. I missed it in upgrade guides.

  8. #18
    Sencha User Misiu's Avatar
    Join Date
    Jun 2012
    Location
    Poland
    Posts
    260

    Default

    Quote Originally Posted by ahameed View Post
    I was able to make it work by:

    1. Instead of overriding onClick, I used click and destroy listeners.
    2. Copy the same code in click listener but instead of callParent code, copy the actual onClick code from source code of Ext.panel.Tool.onClick method. (as Misiu did initially)
    @ahameed I'm glad You managed to convert my code to ExtJS 5.0. If that's not a problem could You share Your code? I plan to move to ExtJS 5.0 at some point so I'll probably will need that code and maybe others.

  9. #19
    Sencha Premium Member
    Join Date
    Mar 2010
    Posts
    10

    Default

    I tried couple of things but final and best solution is the one suggested by skirtle; add privates block around methods. Here is how it would look like:

    Code:
    Ext.define('ExtMVC.view.app.ToolMenu', {
        extend: 'Ext.panel.Tool',
        alias: 'widget.toolmenu',
    
    
        renderTpl: ['<div class="x-menu-tool-hover">' + '</div><img id="{id}-toolEl" src="{blank}" class="{baseCls}-img {baseCls}-{type}' + '{childElCls}" role="presentation"/>'],
    
    
        privates: {
            onClick: function() {
                var me = this,
                returnValue = me.callParent(arguments);
    
    
                if (returnValue && me.items) {
                    if (!me.toolMenu) {
                        me.toolMenu = new Ext.menu.Menu({
                            items: me.items
                        });
                    }
                    me.toolMenu.showAt(0, 0);
                    me.toolMenu.showAt(me.getX() + me.getWidth() - me.toolMenu.getWidth(), me.getY() + me.getHeight() + 10);
                }
    
    
                return returnValue;
            },
            onDestroy: function() {
                Ext.destroyMembers(this, 'toolMenu'); //destructor
                this.callParent();
            }
        }       
    
    
    });

Page 2 of 2 FirstFirst 12

Posting Permissions

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