O'Reilly logo

Ext JS 4 Web Application Development Cookbook by Stuart Ashworth, Andrew Duncan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the color picker in a menu

The Color Picker component provides a straightforward way for the user to select a color from a defined array of color hex codes:

Using the color picker in a menu

This recipe will demonstrate how to use the color picker in a menu to change the body background color. We will use the default 40-color palette that is provided by the framework.

How to do it...

  1. Start by creating a button and add a new instance of a ColorPicker to the button's menu property:
    var button = Ext.create('Ext.button.Button', {
        text: 'Change the Background Color',
        menu: new Ext.menu.ColorPicker({
            ...
        })
    });
  2. Create a Panel with the button in a toolbar that's docked to the top.
    var ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required