Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

You can navigate using arrow keys when the sheet is in edit mode.
If the editor is in edit mode, the status is Enter or Edit. If the editor is not in edit mode, the status is Ready.
In Enter status, Spread commits the current input and navigates or selects other cells if the user uses navigate or select actions. In Edit status, Spread does not commit the current input and navigates or selects other cells if the user uses navigate or select actions.
Typing and double-clicking on an empty cell will cause the cell to go into the Enter status. Double-clicking on a non-empty cell causes the cell to go into the Edit status. If the cell is in Enter status and you click in the editor using the left mouse button, the status changes to Edit. Using the startEdit method is similar to double-clicking.
You can use the editorStatus type to check the edit mode.
Using Code
The following example displays the editor status.你可以在编辑模式下使用方向键进行导航。

如果编辑器在编辑模式下,那么它的状态应该为 Enter 或者 Edit。

如果编辑器不在编辑模式下,那么它的状态应该为 Ready。

在 Enter 模式下,如果用户触发了选择动作,Spread会导航到下一个区域或者单元格并提交当前的输入内容。

在编辑状态下,Spread 将不响应用户出触发的选择动作,输入内容也不会被提交。

在空单元格上双击或者打字将会触发单元格进入 Enter 状态。

在不为空的单元格上双击会让单元格进入 Edit 状态。

如果单元格处于 Enter 状态并且用户使用鼠标左键点击了单元格,单元格的状态将会变为 Edit。

startEdit 方法的行为与用户双击单元格的行为类似。

你可以使用 editorStatus 类型来检查编辑器的模式。


示例代码
以下代码显示了显示了单元格的编辑状态。

JavaScript

Copy Code

<script type="text/javascript">    window.onload = function () {         var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));        var activeSheet = spread.getActiveSheet();
spread.commandManager().register("startEditing", {            canUndo: false,            execute: function (context, options) {                var sheet = context.getSheetFromName(options.sheetName);                if (sheet && !sheet.isEditing()) {                    sheet.startEdit();                }            }        }, 113, false, false, false, false);
        setstatus(activeSheet);        activeSheet.bind(GC.Spread.Sheets.Events.EditorStatusChanged,function(e,args){            setstatus(activeSheet, args.status);        });    }
    function setstatus(activeSheet,status) {        var statusnow = status

activeSheet.editorStatus();        if (statusnow === GC.Spread.Sheets.EditorStatus.ready) {            $("#status").text("Ready");        } else if (statusnow === GC.Spread.Sheets.EditorStatus.enter) {            $("#status").text("Enter");        } else if (statusnow === GC.Spread.Sheets.EditorStatus.edit) {            $("#status").text("Edit");        }    }</script><label id="status" style="margin: 10px">

 

See Also另见
EnterCell Event