您好,您提供的 demo 文件里没有公式栏,无法复现这个问题。
关于我们绑定公式追踪的快捷键部分的代码如下
- let command1 = {
- canUndo: false,
- execute: function(context, options, isUndo) {
- let Commands = GC.Spread.Sheets.Commands
- if (isUndo) {
- Commands = undoTransaction(context, options)
- } else {
- Commands = startTransaction(context, options)
- }
- let sheet = context.getActiveSheet()
- let rowIndex = sheet.getActiveRowIndex()
- let columnIndex = sheet.getActiveColumnIndex()
- let childNodes = sheet.getDependents(rowIndex, columnIndex)
- if (childNodes.length > 0) {
- let targetNode = childNodes[0]
- let targetSheet = context.getSheetFromName(targetNode.sheetName)
- let targetRowIndex = targetNode.row
- let targetColumnIndex = targetNode.col
- context.setActiveSheet(targetNode.sheetName)
- targetSheet.setSelection(targetRowIndex, targetColumnIndex, 1, 1)
- targetSheet.setActiveCell(targetRowIndex, targetColumnIndex)
- }
- Commands.endTransaction(context, options)
- return true
- }
- }
- spread.commandManager().register("searchDependent", command1)
- spread.commandManager().setShortcutKey("searchDependent", 219, true, false, false, false)
- let command2 = {
- canUndo: false,
- execute: function(context, options, isUndo) {
- let Commands = GC.Spread.Sheets.Commands
- if (isUndo) {
- Commands = undoTransaction(context, options)
- } else {
- Commands = startTransaction(context, options)
- }
- let sheet = context.getActiveSheet()
- let rowIndex = sheet.getActiveRowIndex()
- let columnIndex = sheet.getActiveColumnIndex()
- let parentNodes = sheet.getPrecedents(rowIndex, columnIndex)
- if (parentNodes.length > 0) {
- let targetNode = parentNodes[0]
- let targetSheet = context.getSheetFromName(targetNode.sheetName)
- let targetRowIndex = targetNode.row
- let targetColumnIndex = targetNode.col
- context.setActiveSheet(targetNode.sheetName)
- targetSheet.setSelection(targetRowIndex, targetColumnIndex, 1, 1)
- targetSheet.setActiveCell(targetRowIndex, targetColumnIndex)
- }
- Commands.endTransaction(context, options)
- return true
- }
- }
- spread.commandManager().register("searchPrecedent", command2)
- spread.commandManager().setShortcutKey("searchPrecedent", 221, true, false, false, false)
复制代码 |