1. #1
    Sencha User xjpmauricio's Avatar
    Join Date
    Jul 2009
    Location
    Portugal, Setúbal
    Posts
    88
    Vote Rating
    1
    xjpmauricio is on a distinguished road

      0  

    Default Ext.Msg set default button on focus

    Ext.Msg set default button on focus


    Hi, how can i set the default focus on the 'no' button of this message window?

    Code:
        Ext.Msg.show({
                title: 'Message',
                msg: 'Are you sure you want to delete the selected item?',
                buttons: Ext.Msg.YESNO,
                icon: Ext.MessageBox.WARNING,
                width: 300,
                modal: true,
                fn: function (btn) {
                    if (btn != 'yes') return;
                }
            });
    I'm trying to avoid this:
    Code:
    Ext.MessageBox.defaultButton = 2;
    ...because it overrides every instance of this component. It does the focus i need but, i need somekind of config on this instance only.

    I've tried looking at the source code of MessageBox.js but with no success; the method reconfigure does this:
    Code:
    me.defaultFocus = me.msgButtons[i];
    ...but i'm looking for a more simple solution other than having to override the whole component for such a "easy" task.

    I've also tried the defaultFocus config with every possible index and button id's like 'no', etc.

    Any ideias? this one should be simple!

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,197
    Vote Rating
    482
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    This has been corrected in the latest build:

    Code:
    var dlg = Ext.Msg.show({
            title: 'Message',
            msg: 'Are you sure you want to delete the selected item?',
            buttons: Ext.Msg.YESNO,
            icon: Ext.MessageBox.WARNING,
            width: 300,
            modal: true
        });
    
    dlg.defaultButton = 2;
    Scott.

  3. #3
    Sencha User
    Join Date
    May 2008
    Posts
    24
    Vote Rating
    0
    prout_boudin is on a distinguished road

      0  

    Default


    Hi...
    Why not having it passed in the config (cfr defaultFocus) when calling the show or prompt method ? (not supported actually)

    defaultButton is not documented and you have to make a lot of search just to change the focus...

Thread Participants: 2