Changeset 52217 in webkit


Ignore:
Timestamp:
Dec 16, 2009 1:17:08 PM (14 years ago)
Author:
bweinstein@apple.com
Message:

Part of <http://webkit.org/b/32568>.
Web Inspector: Context Menus should be used in more places.

Reviewed by Timothy Hatcher.

Add a context menu entry in the console to clear the console. This
is only shown when there is no user selection of text, because if
there is selection of the text, then we want to give the user the Copy +
Spell Check context menu that they are used to.

  • English.lproj/localizedStrings.js: Added "Clear Console".
  • inspector/front-end/ConsoleView.js:

(WebInspector.ConsoleView.prototype._handleContextMenuEvent):

Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r52214 r52217  
     12009-12-16  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Part of <http://webkit.org/b/32568>.
     6        Web Inspector: Context Menus should be used in more places.
     7       
     8        Add a context menu entry in the console to clear the console. This
     9        is only shown when there is no user selection of text, because if
     10        there is selection of the text, then we want to give the user the Copy +
     11        Spell Check context menu that they are used to.
     12
     13        * English.lproj/localizedStrings.js: Added "Clear Console".
     14        * inspector/front-end/ConsoleView.js:
     15        (WebInspector.ConsoleView.prototype._handleContextMenuEvent):
     16
    1172009-12-16  Brian Weinstein  <bweinstein@apple.com>
    218
  • trunk/WebCore/inspector/front-end/ConsoleView.js

    r52203 r52217  
    9393
    9494    var shortcut;
    95     var handler = this.clearMessages.bind(this, true);
     95    var clearConsoleHandler = this.clearMessages.bind(this, true);
    9696
    9797    shortcut = WebInspector.KeyboardShortcut.makeKey("k", WebInspector.KeyboardShortcut.Modifiers.Meta);
    98     this._shortcuts[shortcut] = handler;
     98    this._shortcuts[shortcut] = clearConsoleHandler;
    9999    this._shortcuts[shortcut].isMacOnly = true;
    100100    shortcut = WebInspector.KeyboardShortcut.makeKey("l", WebInspector.KeyboardShortcut.Modifiers.Ctrl);
    101     this._shortcuts[shortcut] = handler;
    102 
     101    this._shortcuts[shortcut] = clearConsoleHandler;
     102
     103    // Since the Context Menu for the Console View will always be the same, we can create it in
     104    // the constructor.
     105    this._contextMenu = new WebInspector.ContextMenu();
     106    this._contextMenu.appendItem(WebInspector.UIString("Clear Console"), clearConsoleHandler);
     107    this.messagesElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
     108   
    103109    this._customFormatters = {
    104110        "object": this._formatobject,
     
    372378        this.clearMessages(true);
    373379    },
     380   
     381    _handleContextMenuEvent: function(event)
     382    {
     383        if (!window.getSelection().isCollapsed) {
     384            // If there is a selection, we want to show our normal context menu
     385            // (with Copy, etc.), and not Clear Console.
     386            return;
     387        }
     388
     389        this._contextMenu.show(event);
     390    },
    374391
    375392    _messagesSelectStart: function(event)
Note: See TracChangeset for help on using the changeset viewer.