打印版式

Class Ext.menu.ColorMenu

Package:Ext.menu
Class:ColorMenu
Extends:Menu
Defined In:ColorMenu.js
A menu containing a Ext.menu.ColorItem component (which provides a basic color picker).

属性   -  方法   -  事件   -  设置选项

公共属性

属性 定义对象
  palette : ColorPalette ColorMenu
The Ext.ColorPalette instance for this ColorMenu

公共方法

方法 定义对象
  ColorMenu(Object config) ColorMenu
Creates a new ColorMenu
  add(Mixed args) : Ext.menu.Item Menu
Addds one or more items of any type supported by the Menu class, or that can be converted into menu items. Any of the...
  addElement(String/HTMLElement/Ext.Element el) : Ext.menu.Item Menu
Adds an Ext.Element object to the menu
  addEvents(Object object) : void Observable
将对象中没有的事件从给出的对象中复制过来。
  addItem(Ext.menu.Item item) : Ext.menu.Item Menu
Adds an existing object based on Ext.menu.Item to the menu
  addListener(String eventName, Function handler, [Object scope], [Object options]) : void Observable
为该组件加入事件处理器函数
  addMenuItem(Object config) : Ext.menu.Item Menu
Creates a new Ext.menu.Item based an the supplied config object and adds it to the menu
  addSeparator() : Ext.menu.Item Menu
Adds a separator bar to the menu
  addText(String text) : Ext.menu.Item Menu
Creates a new Ext.menu.TextItem with the supplied text and adds it to the menu
  fireEvent(String eventName, Object... args) : Boolean Observable
触发指定的事件, 并将参数传入(至少要有事件名称)。
  getEl() : Ext.Element Menu
Returns this menu's underlying Ext.Element object
  hasListener(String eventName) : Boolean Observable
检查该对象是否拥有指定事件的侦听器
  hide([Boolean deep]) : void Menu
Hides this menu and optionally all parent menus
  insert(Number index, Ext.menu.Item item) : Ext.menu.Item Menu
Inserts an existing object based on Ext.menu.Item to the menu at a specified index
  isVisible() : void Menu
Read-only. Returns true if the menu is currently displayed, else false.
  on(String eventName, Function handler, [Object options]) : void Observable
为该组件加入事件处理器函数, addListener 的简写方式
  purgeListeners() : void Observable
从对象身上移除所有的侦听器
  remove(Ext.menu.Item item) : void Menu
Removes an Ext.menu.Item from the menu and destroys the object
  removeAll() : void Menu
Removes and destroys all items in the menu
  removeListener(String eventName, Function handler, [Object scope]) : void Observable
移除侦听器
  show(String/HTMLElement/Ext.Element element, [String position], [Ext.menu.Menu parentMenu]) : void Menu
Displays this menu relative to another element
  showAt(Array xyPosition, [Ext.menu.Menu parentMenu]) : void Menu
Displays this menu at a specific xy position
  un(String eventName, Function handler, [Object scope]) : void Observable
移除侦听器, removeListener 的简写方式

公共事件

事件 定义对象
  beforehide : (Ext.menu.Menu this) Menu
Fires before this menu is hidden
  beforeshow : (Ext.menu.Menu this) Menu
Fires before this menu is displayed
  click : (Ext.menu.Menu this, String menuItemId, Ext.EventObject e) Menu
Fires when this menu is clicked (or when the enter key is pressed while it is active)
  hide : (Ext.menu.Menu this) Menu
Fires after this menu is hidden
  itemclick : (Ext.menu.BaseItem baseItem, Ext.EventObject e) Menu
Fires when a menu item contained in this menu is clicked
  mouseout : (Ext.menu.Menu this, Ext.EventObject e, String menuItemId) Menu
Fires when the mouse exits this menu
  mouseover : (Ext.menu.Menu this, Ext.EventObject e, String menuItemId) Menu
Fires when the mouse is hovering over this menu
  select : (ColorPalette palette, String color) ColorMenu
  show : (Ext.menu.Menu this) Menu
Fires after this menu is displayed

设置选项

设置选项 定义对象
  allowOtherMenus : Boolean Menu
True to allow multiple menus to be displayed at the same time (defaults to false)
  defaultAlign : String Menu
The default {@link Ext.Element#alignTo) anchor position value for this menu relative to its element of origin (defaul...
  minWidth : Number Menu
The minimum width of the menu in pixels (defaults to 120)
  shadow : Boolean/String Menu
True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right shadow (defaults to "si...
  subMenuAlign : String Menu
The {@link Ext.Element#alignTo) anchor position value to use for submenus of this menu (defaults to "tl-tr?")

属性详情

palette

public ColorPalette palette
The Ext.ColorPalette instance for this ColorMenu
This property is defined by ColorMenu.

构造函数

ColorMenu

public function ColorMenu(Object config)
Creates a new ColorMenu
参数:
  • config : Object
    Configuration options

方法详情

add

public function add(Mixed args)
Addds one or more items of any type supported by the Menu class, or that can be converted into menu items. Any of the following are valid:
  • Any menu item object based on Ext.menu.Item
  • An HTMLElement object which will be converted to a menu item
  • A menu item config object that will be created as a new menu item
  • A string, which can either be '-' or 'separator' to add a menu separator, otherwise it will be converted into a Ext.menu.TextItem and added
Usage:

// Create the menu
var menu = new Ext.menu.Menu();

// Create a menu item to add by reference
var menuItem = new Ext.menu.Item({ text: 'New Item!' });

// Add a bunch of items at once using different methods.
// Only the last item added will be returned.
var item = menu.add(
    menuItem,                // add existing item by ref
    'Dynamic Item',          // new TextItem
    '-',                     // new separator
    { text: 'Config Item' }  // new item by config
);
参数:
  • args : Mixed
    One or more menu items, menu item configs or other objects that can be converted to menu items
返回:
  • Ext.menu.Item
    The menu item that was added, or the last one if multiple items were added
This method is defined by Menu.

addElement

public function addElement(String/HTMLElement/Ext.Element el)
Adds an Ext.Element object to the menu
参数:
  • el : String/HTMLElement/Ext.Element
    The element or DOM node to add, or its id
返回:
  • Ext.menu.Item
    The menu item that was added
This method is defined by Menu.

addEvents

public function addEvents(Object object)
将对象中没有的事件从给出的对象中复制过来。给出的对象必须也继承于 Observable 对象此方法才会有效果。
参数:
  • object : Object
    要复制事件的源对象
返回:
  • void
This method is defined by Observable.

addItem

public function addItem(Ext.menu.Item item)
Adds an existing object based on Ext.menu.Item to the menu
参数:
  • item : Ext.menu.Item
    The menu item to add
返回:
  • Ext.menu.Item
    The menu item that was added
This method is defined by Menu.

addListener

public function addListener(String eventName, Function handler, [Object scope], [Object options])
为组件添加一个事件监听器
参数:
  • eventName : String
    侦听事件的类型
  • handler : Function
    事件调用的方法
  • scope : Object
    (可选)处理函数执行的作用域。处理函数 "this" 的内容。
  • options : Object
    (可选)一个包含处理设置属性的对象。可以包含下列的属性:
    • scope {Object} 处理函数执行的作用域。处理函数 "this" 的内容。
    • delegate {String} 一个简单的选择器用来过滤目标或查找目标的子节点。
    • stopEvent {Boolean} 值为 True 时用来中止事件。那样将中止传播,并防止缺省动作。
    • preventDefault {Boolean} 值为 True 时用来防止缺省动作。
    • stopPropagation {Boolean} 值为 True 时用来中止事件传播。
    • normalized {Boolean} 值为 False 时向处理函数传递浏览器事件用以代替 Ext.EventObject 对象。
    • delay {Number} 当事件触发后启用处理函数的延迟微秒数。
    • single {Boolean} 值为 True 时将添加一个处理函数用来处理下个触发的事件,并在处理完后移除。
    • buffer {Number} 使处理函数计划在由 Ext.util.DelayedTask 指定的微秒数后执行。如果事件在延迟期间再次触发,原来的处理函数将不再启动,而是由新的计划代替。

    组合选项
    使用选项参数可以组合不同类型的监听器:

    下面是一个标准的、延迟执行的、一次性的监听器,将会自动停止事件并传递一个自定义的参数(forumId)

    代码:
    el.on('click', this.onClick, this, { single: true, delay: 100, stopEvent : true, forumId: 4 });

    这个方法也允许传递的单个参数是一个包含多个指定处理函数的设置对象。

    一次调用多个处理函数
    代码:

    el.on({ 'click' : { fn: this.onClick scope: this, delay: 100 }, 'mouseover' : { fn: this.onMouseOver scope: this }, 'mouseout' : { fn: this.onMouseOut scope: this } });

    或者简写为:
    代码:

    el.on({ 'click' : this.onClick, 'mouseover' : this.onMouseOver, 'mouseout' : this.onMouseOut scope: this });
返回:
  • void
This method is defined by Observable.

addMenuItem

public function addMenuItem(Object config)
Creates a new Ext.menu.Item based an the supplied config object and adds it to the menu
参数:
  • config : Object
    A MenuItem config object
返回:
  • Ext.menu.Item
    The menu item that was added
This method is defined by Menu.

addSeparator

public function addSeparator()
Adds a separator bar to the menu
参数:
  • 无。
返回:
  • Ext.menu.Item
    The menu item that was added
This method is defined by Menu.

addText

public function addText(String text)
Creates a new Ext.menu.TextItem with the supplied text and adds it to the menu
参数:
  • text : String
    The text to display in the menu item
返回:
  • Ext.menu.Item
    The menu item that was added
This method is defined by Menu.

fireEvent

public function fireEvent(String eventName, Object... args)
触发指定的事件并给出参数(至少要有事件名称)。
参数:
  • eventName : String
  • args : Object...
    传入处理函数的参数
返回:
  • Boolean
    如果任何处理函数返回 false 则返回值为 false, 否则返回 true。
This method is defined by Observable.

getEl

public function getEl()
Returns this menu's underlying Ext.Element object
参数:
  • 无。
返回:
  • Ext.Element
    The element
This method is defined by Menu.

hasListener

public function hasListener(String eventName)
检查该对象是否拥有指定事件的侦听器
参数:
  • eventName : String
    查询事件之名称
返回:
  • Boolean
    值为 True 值表示事件监听器存在, 否则值为 false。
This method is defined by Observable.

hide

public function hide([Boolean deep])
Hides this menu and optionally all parent menus
参数:
  • deep : Boolean
    (可选) True to hide all parent menus recursively, if any (defaults to false)
返回:
  • void
This method is defined by Menu.

insert

public function insert(Number index, Ext.menu.Item item)
Inserts an existing object based on Ext.menu.Item to the menu at a specified index
参数:
  • index : Number
    The index in the menu's list of current items where the new item should be inserted
  • item : Ext.menu.Item
    The menu item to add
返回:
  • Ext.menu.Item
    The menu item that was added
This method is defined by Menu.

isVisible

public function isVisible()
Read-only. Returns true if the menu is currently displayed, else false.
参数:
  • 无。
返回:
  • void
This method is defined by Menu.

on

public function on(String eventName, Function handler, [Object options])
为该组件加入事件处理器函数, addListener 的简写方式
参数:
  • eventName : String
    侦听事件的类型
  • handler : Function
    事件调用的方法
  • options : Object
    (可选)
返回:
  • void
This method is defined by Observable.

purgeListeners

public function purgeListeners()
从对象身上移除所有的侦听器
参数:
  • 无。
返回:
  • void
This method is defined by Observable.

remove

public function remove(Ext.menu.Item item)
Removes an Ext.menu.Item from the menu and destroys the object
参数:
  • item : Ext.menu.Item
    The menu item to remove
返回:
  • void
This method is defined by Menu.

removeAll

public function removeAll()
Removes and destroys all items in the menu
参数:
  • 无。
返回:
  • void
This method is defined by Menu.

removeListener

public function removeListener(String eventName, Function handler, [Object scope])
移除侦听器
参数:
  • eventName : String
    侦听事件的类型
  • handler : Function
    删除的处理函数
  • scope : Object
    (可选) The scope (this object) for the handler
返回:
  • void
This method is defined by Observable.

show

public function show(String/HTMLElement/Ext.Element element, [String position], [Ext.menu.Menu parentMenu])
Displays this menu relative to another element
参数:
  • element : String/HTMLElement/Ext.Element
    The element to align to
  • position : String
    (可选) The Ext.Element.alignTo anchor position to use in aligning to the element (defaults to this.defaultAlign)
  • parentMenu : Ext.menu.Menu
    (可选) This menu's parent menu, if applicable (defaults to undefined)
返回:
  • void
This method is defined by Menu.

showAt

public function showAt(Array xyPosition, [Ext.menu.Menu parentMenu])
Displays this menu at a specific xy position
参数:
  • xyPosition : Array
    Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
  • parentMenu : Ext.menu.Menu
    (可选) This menu's parent menu, if applicable (defaults to undefined)
返回:
  • void
This method is defined by Menu.

un

public function un(String eventName, Function handler, [Object scope])
移除侦听器, removeListener 的简写方式
参数:
  • eventName : String
    侦听事件的类型
  • handler : Function
    删除的处理函数
  • scope : Object
    (可选) The scope (this object) for the handler
返回:
  • void
This method is defined by Observable.

事件详情

beforehide

public event beforehide
Fires before this menu is hidden
Subscribers will be called with the following parameters:
  • this : Ext.menu.Menu
This event is defined by Menu.

beforeshow

public event beforeshow
Fires before this menu is displayed
Subscribers will be called with the following parameters:
  • this : Ext.menu.Menu
This event is defined by Menu.

click

public event click
Fires when this menu is clicked (or when the enter key is pressed while it is active)
Subscribers will be called with the following parameters:
  • this : Ext.menu.Menu
  • menuItemId : String
    The id of the menu item that was clicked
  • e : Ext.EventObject
This event is defined by Menu.

hide

public event hide
Fires after this menu is hidden
Subscribers will be called with the following parameters:
  • this : Ext.menu.Menu
This event is defined by Menu.

itemclick

public event itemclick
Fires when a menu item contained in this menu is clicked
Subscribers will be called with the following parameters:
  • baseItem : Ext.menu.BaseItem
    The BaseItem that was clicked
  • e : Ext.EventObject
This event is defined by Menu.

mouseout

public event mouseout
Fires when the mouse exits this menu
Subscribers will be called with the following parameters:
  • this : Ext.menu.Menu
  • e : Ext.EventObject
  • menuItemId : String
    The id of the menu item that the mouse has exited
This event is defined by Menu.

mouseover

public event mouseover
Fires when the mouse is hovering over this menu
Subscribers will be called with the following parameters:
  • this : Ext.menu.Menu
  • e : Ext.EventObject
  • menuItemId : String
    The id of the menu item that the mouse is over
This event is defined by Menu.

select

public event select
Subscribers will be called with the following parameters:
  • palette : ColorPalette
  • color : String
This event is defined by ColorMenu.

show

public event show
Fires after this menu is displayed
Subscribers will be called with the following parameters:
  • this : Ext.menu.Menu
This event is defined by Menu.

设置详情

allowOtherMenus

allowOtherMenus : Boolean
True to allow multiple menus to be displayed at the same time (defaults to false)
This config option is defined by Menu.

defaultAlign

defaultAlign : String
The default {@link Ext.Element#alignTo) anchor position value for this menu relative to its element of origin (defaults to "tl-bl?")
This config option is defined by Menu.

minWidth

minWidth : Number
The minimum width of the menu in pixels (defaults to 120)
This config option is defined by Menu.

shadow

shadow : Boolean/String
True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right shadow (defaults to "sides")
This config option is defined by Menu.

subMenuAlign

subMenuAlign : String
The {@link Ext.Element#alignTo) anchor position value to use for submenus of this menu (defaults to "tl-tr?")
This config option is defined by Menu.

Ext - Copyright © 2006-2007 Ext JS, LLC
All rights reserved.