Jump to content

Toggle Desktop


SISBLU Software

Recommended Posts

4 hours ago, Daha Software said:

How can I do for Desktop?

Hello,

You can use this config for now:

UniButton1 ->

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniButton1.JSInterface.JSConfig('enableToggle', [True]);
end;
function click(sender, e, eOpts)
{
    alert(sender.pressed)
}

 

Link to comment
Share on other sites

On 7/6/2020 at 9:15 PM, Daha Software said:

This already exists in UNIGUI Touch. That would help a lot if it existed for DESKTOP

 

21 hours ago, fraxzi said:

+1, I am also looking that kinda component too in Desktop.

 

Hello,

Simple implementation on a desktop browser.

1. MainForm.Script:

Ext.define('Ext.field.Toggle', {
    extend: 'Ext.slider.Single',

    xtype: 'toggle',
    minValue: 0,
    maxValue: 1,

    width: 80,

    onRender: function(parentNode, containerIdx) {
        this.callParent([parentNode, containerIdx]);
        this.publishValue();
    },

    setValue: function(thumbIndex, value) {
        value = value ? 1 : 0;
        this.callParent([value]);

        this.bodyEl.toggleCls('x-togglefield-on', value);
        this.publishValue();
    },

    getValue: function() {
        return this.callParent([0]) ? true : false;
    }
});

2. CustomCSS:

.x-togglefield-on .x-slider:before {
    background-color: green;
}

 

3. UniPanel1:

Caption = ''

function beforeInit(sender, config)
{
    config.layout = {
        type: 'vbox',
        padding: 5
    };
    
    config.items = [
      {
          xtype: 'toggle',
          reference: 'firsttoggle',
          listeners: {
              change: function(field, newValue, oldValue) {
                  console.log(field.reference + ' Value of this toggle has changed:', (newValue) ? 'ON' : 'OFF');
              }
          }
      },
      {
          xtype: 'toggle',
          reference: 'secondtoggle',
          listeners: {
              change: function(field, newValue, oldValue) {
                  console.log(field.reference + ' Value of this toggle has changed:', (newValue) ? 'ON' : 'OFF');
              }
          }
      }
    ]
}

 

4. Results:

Theme: Triton

toggleTriton.png.4e8662a3fd832457a14599adc072ef3c.png

Theme: Crisp

toggleCrisp.png.6ebbb874f0beabaae137ec8e623f56a6.png

 

5. Sources:

https://fiddle.sencha.com/#view/editor&fiddle/27ac

https://docs.sencha.com/extjs/7.0.0/modern/Ext.field.Toggle.html

Link to comment
Share on other sites

  • 2 months later...
  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...