Changeset 51119 in webkit


Ignore:
Timestamp:
Nov 18, 2009 10:12:07 AM (14 years ago)
Author:
bweinstein@apple.com
Message:

Fixes <http://webkit.org/b/31606>.
Web Inspector: Enter/Return key should enter edit mode for Editable Fields.

Reviewed by Pavel Feldman.

This implements Enter starting editing mode in an editable DataGrid. If the
DataGrid is editable and the user hits return, startEditing the first child
of the selected node. Also refactored some editing functions to take an
event target instead of the event itself, because the functions only needed
the target. Lastly, added had return in editing mode stop propogation, because
when enter was hit to confirm text, it would propagate back to the datagrid
and try to start editing again.

  • inspector/front-end/DataGrid.js:

(WebInspector.DataGrid.prototype._ondblclick):
(WebInspector.DataGrid.prototype._startEditing):
(WebInspector.DataGrid.prototype.handleKeyEvent):
(WebInspector.DataGrid.prototype.dataGridNodeFromEvent):
(WebInspector.DataGrid.prototype._mouseDownInDataTable):
(WebInspector.DataGrid.prototype._clickInDataTable):

  • inspector/front-end/inspector.js:

(WebInspector.startEditing.element.handleKeyEvent):
(WebInspector.startEditing):

Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r51118 r51119  
     12009-11-17  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Fixes <http://webkit.org/b/31606>.
     6        Web Inspector: Enter/Return key should enter edit mode for Editable Fields.
     7       
     8        This implements Enter starting editing mode in an editable DataGrid. If the
     9        DataGrid is editable and the user hits return, startEditing the first child
     10        of the selected node. Also refactored some editing functions to take an
     11        event target instead of the event itself, because the functions only needed
     12        the target. Lastly, added had return in editing mode stop propogation, because
     13        when enter was hit to confirm text, it would propagate back to the datagrid
     14        and try to start editing again.
     15
     16        * inspector/front-end/DataGrid.js:
     17        (WebInspector.DataGrid.prototype._ondblclick):
     18        (WebInspector.DataGrid.prototype._startEditing):
     19        (WebInspector.DataGrid.prototype.handleKeyEvent):
     20        (WebInspector.DataGrid.prototype.dataGridNodeFromEvent):
     21        (WebInspector.DataGrid.prototype._mouseDownInDataTable):
     22        (WebInspector.DataGrid.prototype._clickInDataTable):
     23        * inspector/front-end/inspector.js:
     24        (WebInspector.startEditing.element.handleKeyEvent):
     25        (WebInspector.startEditing):
     26
    1272009-11-18  Ben Murdoch  <benm@google.com>
    228
  • trunk/WebCore/inspector/front-end/DataGrid.js

    r50613 r51119  
    143143            return;
    144144
    145         this._startEditing(event);
     145        this._startEditing(event.target);
    146146    },
    147147
     
    157157    },
    158158
    159     _startEditing: function(event)
    160     {
    161         var element = event.target.enclosingNodeOrSelfWithNodeName("td");
     159    _startEditing: function(target)
     160    {
     161        var element = target.enclosingNodeOrSelfWithNodeName("td");
    162162        if (!element)
    163163            return;
    164164
    165         this._editingNode = this.dataGridNodeFromEvent(event);
     165        this._editingNode = this.dataGridNodeFromNode(target);
    166166        if (!this._editingNode) {
    167167            if (!this.creationNode)
     
    521521                this._deleteCallback(this.selectedNode);
    522522            }
     523        } else if (isEnterKey(event)) {
     524            if (this._editCallback) {
     525                handled = true;
     526                // The first child of the selected element is the <td class="0-column">,
     527                // and that's what we want to edit.
     528                this._startEditing(this.selectedNode._element.children[0]);
     529            }
    523530        }
    524531
     
    551558    },
    552559
    553     dataGridNodeFromEvent: function(event)
    554     {
    555         var rowElement = event.target.enclosingNodeOrSelfWithNodeName("tr");
     560    dataGridNodeFromNode: function(target)
     561    {
     562        var rowElement = target.enclosingNodeOrSelfWithNodeName("tr");
    556563        return rowElement._dataGridNode;
    557564    },
     
    598605    _mouseDownInDataTable: function(event)
    599606    {
    600         var gridNode = this.dataGridNodeFromEvent(event);
     607        var gridNode = this.dataGridNodeFromNode(event.target);
    601608        if (!gridNode || !gridNode.selectable)
    602609            return;
     
    616623    _clickInDataTable: function(event)
    617624    {
    618         var gridNode = this.dataGridNodeFromEvent(event);
     625        var gridNode = this.dataGridNodeFromNode(event.target);
    619626        if (!gridNode || !gridNode.hasChildren)
    620627            return;
  • trunk/WebCore/inspector/front-end/inspector.js

    r50947 r51119  
    16811681            editingCommitted.call(element);
    16821682            event.preventDefault();
     1683            event.stopPropagation();
     1684            event.handled = true;
    16831685        } else if (event.keyCode === 27) { // Escape key
    16841686            editingCancelled.call(element);
Note: See TracChangeset for help on using the changeset viewer.