1. #1
    Sencha Premium Member intellix's Avatar
    Join Date
    Mar 2012
    Location
    UK + Malta
    Posts
    263
    Vote Rating
    18
    intellix will become famous soon enough

      0  

    Default Are you sure you want to untoggle that SegmentedButton?

    Are you sure you want to untoggle that SegmentedButton?


    Ok so the project I'm working on required a confirmation dialog to ask the user if they were sure they wanted to untoggle a SegmentedButton. This is the first time for me using ExtJS, ST2 so you may not appreciate what I've created... but here it is:

    Inside Ext.application you need to specify that you want to use an over-ride which exists as app/view/override/SegmentedButton.js
    Code:
    Ext.application({
        requires: [
            'App.view.override.SegmentedButton'
        ],
    
        // rest of it
    Override (to allow beforetoggle event):
    Code:
    Ext.define('App.view.override.SegmentedButton', {
        override: 'Ext.SegmentedButton',
    
    
        initialize: function () {
            var me = this;
    
    
            me.on({
                delegate: '> button',
                scope: me,
                tap: 'onButtonPress'
            });
    
    
            me.callParent();
        },
    
    
        onButtonPress: function (button) {
    
    
            var me = this,
                pressedButtons = me.getPressedButtons() || [],
                buttons = [],
                alreadyPressed;
    
    
            wasPressed = (buttons.indexOf(button) !== -1) || (pressedButtons.indexOf(button) !== -1);
    
    
            me.fireEvent('beforetoggle', me, button, wasPressed);
    
    
        }
        
    });
    beforetoggle event within my controller which is called on 'beforetoggle':
    Code:
    onSegmentedbuttonBeforeToggle: function(segmentedbutton, button, wasPressed, options) {
            // Remove ability to depress it so it doesnt change until confirmed
            segmentedbutton.setAllowDepress(false);
    
    
            // Check if button is already down
            if (wasPressed) {
    
    
                // Is user sure he wants to remove that selection?
                Ext.Msg.confirm("Confirmation", "Are you sure you want to remove that selection?", function (reply) {
    
    
                    if (reply === 'yes') {
                        segmentedbutton.setAllowDepress(true);
                        segmentedbutton.onButtonRelease(button);
                    }
    
    
                });
    
    
            }
        },

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,735
    Vote Rating
    756
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I would think this would be better suited for a plugin or an extension of segmentedbutton. If you use an override, you override all segmentedbuttons which you may not want.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar