Home | History | Annotate | Download | only in ui

Lines Matching full:menu

8   const Menu = cr.ui.Menu;
19 * The menu that we are currently showing.
20 * @type {cr.ui.Menu}
23 get menu() {
28 * Shows a menu as a context menu.
31 * @param {!cr.ui.Menu} menu The menu to show.
33 showMenu: function(e, menu) {
34 this.menu_ = menu;
36 menu.style.display = 'block';
37 // when the menu is shown we steal all keyboard events.
38 var doc = menu.ownerDocument;
43 menu.addEventListener('contextmenu', this);
44 menu.addEventListener('activate', this);
45 this.positionMenu_(e, menu);
49 * Hide the currently shown menu.
52 var menu = this.menu;
53 if (!menu)
56 menu.style.display = 'none';
57 var doc = menu.ownerDocument;
62 menu.removeEventListener('contextmenu', this);
63 menu.removeEventListener('activate', this);
64 menu.selectedIndex = -1;
67 // On windows we might hide the menu in a right mouse button up and if
68 // that is the case we wait some short period before we allow the menu
74 * Positions the menu
76 * @param {!cr.ui.Menu} menu The menu to position.
79 positionMenu_: function(e, menu) {
84 // When the user presses the context menu key (on the keyboard) we need
98 positionPopupAtPoint(x, y, menu);
111 // context menu key or Shift-F10
121 // Context menu is handled even when we have no menu.
122 if (e.type != 'contextmenu' && !this.menu)
127 if (!this.menu.contains(e.target))
137 // If the menu is visible we let it handle all the keyboard events.
138 } else if (this.menu) {
139 this.menu.handleKeyDown(e);
152 if ((!this.menu || !this.menu.contains(e.target)) &&
174 element.__defineSetter__('contextMenu', function(menu) {
177 if (typeof menu == 'string' && menu[0] == '#') {
178 menu = this.ownerDocument.getElementById(menu.slice(1));
179 cr.ui.decorate(menu, Menu);
182 if (menu === oldContextMenu)
185 if (oldContextMenu && !menu) {
190 if (menu && !oldContextMenu) {
196 this.contextMenu_ = menu;
198 if (menu && menu.id)
199 this.setAttribute('contextmenu', '#' + menu.id);
201 cr.dispatchPropertyChange(this, 'contextMenu', menu, oldContextMenu);
207 * menu when the context menu is not opened using a mouse position.
217 * The singleton context menu handler.