SpreadsheetEdit
Package: Libraries.Interface.Undo · Inherits from: Libraries.Language.Object, Libraries.Interface.Undo.Edit
The SpreadsheetEdit class is one step a Spreadsheet can undo and redo: cells typed, cleared, pasted or replaced, rows added or removed, or columns added or removed. It keeps copies of the rows as they were before and after the step, and where the selection was. The Spreadsheet makes these as the user edits and adds them to its SpreadsheetEditManager, so most users won't need this class directly.
Example Code
use Libraries.Interface.Controls.Spreadsheet
use Libraries.Interface.Undo.SpreadsheetEditManager
Spreadsheet sheet
sheet:LoadFromCommaSeparatedValue("a,b")
sheet:Select(0, 0)
sheet:ClearSelectionAsUser()
SpreadsheetEditManager edits = sheet:GetEditManager()
edits:Undo()
output sheet:GetText(0, 0)
Variables
integer INSERTED_ROWS: Rows were put in at an index.integer ROWS: Some rows changed in place; rows may have been added at the end.integer REMOVED_ROWS: Rows were taken out at an index.integer EVERYTHING: Everything changed, as columns being added or removed does.
Actions
GetMode()
This action returns the kind of step: ROWS, INSERTED_ROWS, REMOVED_ROWS or EVERYTHING.
Returns
integer: The kind of step.
GetRedoName()
This action returns "Redo" and the step's name.
Returns
text: The name for a Redo menu item.
GetUndoName()
This action returns "Undo" and the step's name, such as "Undo Typing in C2".
Returns
text: The name for an Undo menu item.
Redo()
This action does the step again, after it was undone.
SetEverything(Libraries.Containers.Array<Libraries.Interface.Controls.Support.SpreadsheetRow> allBefore, Libraries.Containers.Array<number> widthsBefore, Libraries.Containers.Array<Libraries.Interface.Controls.Support.SpreadsheetRow> allAfter, Libraries.Containers.Array<number> widthsAfter)
This action records every row and the column widths before and after, for an EVERYTHING step. The Spreadsheet calls it.
Parameters
allBeforeLibraries.Containers.Array<Libraries.Interface.Controls.Support.SpreadsheetRow>: Copies of every row before.widthsBeforeLibraries.Containers.Array<number>: The column widths before.allAfterLibraries.Containers.Array<Libraries.Interface.Controls.Support.SpreadsheetRow>: Copies of every row after.widthsAfterLibraries.Containers.Array<number>: The column widths after.
SetMovedRows(integer index, Libraries.Containers.Array<Libraries.Interface.Controls.Support.SpreadsheetRow> rows)
This action records rows put in or taken out at an index, for an INSERTED_ROWS or REMOVED_ROWS step. The Spreadsheet calls it.
Parameters
indexinteger: Where the rows were put in or taken out.rowsLibraries.Containers.Array<Libraries.Interface.Controls.Support.SpreadsheetRow>: Copies of the rows.
SetRows(Libraries.Containers.Array<integer> indices, Libraries.Containers.Array<Libraries.Interface.Controls.Support.SpreadsheetRow> before, Libraries.Containers.Array<Libraries.Interface.Controls.Support.SpreadsheetRow> after, integer countBefore, integer countAfter)
This action records changed rows, for a ROWS step. The Spreadsheet calls it.
Parameters
indicesLibraries.Containers.Array<integer>: The rows changed.beforeLibraries.Containers.Array<Libraries.Interface.Controls.Support.SpreadsheetRow>: Copies of those rows before, undefined where a row didn't exist.afterLibraries.Containers.Array<Libraries.Interface.Controls.Support.SpreadsheetRow>: Copies of those rows after, undefined where a row doesn't exist.countBeforeinteger: How many rows there were before.countAfterinteger: How many rows there are after.
SetSelections(Libraries.Containers.Array<integer> selectionBefore, Libraries.Containers.Array<integer> selectionAfter)
This action records where the selection was before and after the step. Each array holds the row, the column, the anchor's row, the anchor's column and the kind. The Spreadsheet calls it.
Parameters
selectionBeforeLibraries.Containers.Array<integer>: The selection before.selectionAfterLibraries.Containers.Array<integer>: The selection after.
Setup(Libraries.Interface.Controls.Spreadsheet sheet, integer mode, text name)
This action sets the spreadsheet, the kind of step and its name, such as "Typing in C2". The Spreadsheet calls it.
Parameters
sheetLibraries.Interface.Controls.Spreadsheet: The spreadsheet the step belongs to.modeinteger: ROWS, INSERTED_ROWS, REMOVED_ROWS or EVERYTHING.nametext: What the step did, for an Undo menu item.
Undo()
This action puts the spreadsheet back as it was before the step.