[]
        
(Showing Draft Content)

GC.Spread.Sheets.CellTypes.Button

Class: Button

Sheets.CellTypes.Button

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Button()

Represents a button cell.

example

//This example creates a button cell.
var spread = new GC.Spread.Sheets.Workbook();
var sheet = spread.getActiveSheet();
var cellType = new GC.Spread.Sheets.CellTypes.Button();
cellType.buttonBackColor("#FFFF00");
cellType.text("this is a button");
sheet.setCellType(1,1,cellType);
//Bind event
spread.bind(GC.Spread.Sheets.Events.ButtonClicked, function (e, args) {
    var sheet = args.sheet, row = args.row, col = args.col;
    var cellType = sheet.getCellType(row, col);
    if (cellType instanceof GC.Spread.Sheets.CellTypes.Button) {
        alert("Button Clicked");
    }
});

Overrides

Base.constructor

Properties

typeName

typeName: string

Represents the type name string used for supporting serialization.

Inherited from

Base.typeName

Methods

activateEditor

activateEditor(editorContext, cellStyle, cellRect, context?): void

Activates the editor, including setting properties or attributes for the editor and binding events for the editor.

Parameters

Name Type Description
editorContext HTMLElement The DOM element that was created by the createEditorElement method.
cellStyle Style The cell's actual style.
cellRect Rect The cell's layout information.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

void

Inherited from

Base.activateEditor


buttonBackColor

buttonBackColor(value?): any

Gets or sets the button's background color.

example

//This example creates a button cell.
var cellType = new GC.Spread.Sheets.CellTypes.Button();
cellType.buttonBackColor("#FFFF00");
cellType.text("this is a button");
activeSheet.getCell(0, 2).cellType(cellType);

Parameters

Name Type Description
value? string The button's background color.

Returns

any

If no value is set, returns the background color; otherwise, returns the button cell type.


createEditorElement

createEditorElement(context?): HTMLElement

Creates a DOM element then returns it.

Parameters

Name Type Description
context? any The context associated with the cell type. See the Remarks for more information.

Returns

HTMLElement

Returns a DOM element.

Inherited from

Base.createEditorElement


deactivateEditor

deactivateEditor(editorContext, context?): void

Deactivates the editor, such as unbinding events for editor.

Parameters

Name Type Description
editorContext HTMLElement The DOM element that was created by the createEditorElement method.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

void

Inherited from

Base.deactivateEditor


focus

focus(editorContext, context?): void

Focuses the editor DOM element.

Parameters

Name Type Description
editorContext HTMLElement The DOM element that was created by the createEditorElement method.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

void

Inherited from

Base.focus


format

format(value, format, formattedData?, context?): string

Formats a value with the specified format to a string.

Parameters

Name Type Description
value any The object value to format.
format string | GeneralFormatter The format.
formattedData? FormattedData the formatted data.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

string

Returns the formatted string.

Inherited from

Base.format


fromJSON

fromJSON(settings): void

Loads the object state from the specified JSON string.

Parameters

Name Type Description
settings any The cell type data from deserialization.

Returns

void

Inherited from

Base.fromJSON


getAutoFitHeight

getAutoFitHeight(value, text, cellStyle, zoomFactor, context?): number

Gets a cell's height that can be used to handle the row's automatic fit.

Parameters

Name Type Description
value any The cell's value.
text string The cell's text.
cellStyle Style The cell's actual value.
zoomFactor number The current sheet's zoom factor.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

number

Returns the cell's height that can be used to handle the row's automatic fit.

Inherited from

Base.getAutoFitHeight


getAutoFitWidth

getAutoFitWidth(value, text, cellStyle, zoomFactor, context?): number

Gets a cell's width that can be used to handle the column's automatic fit.

Parameters

Name Type Description
value any The cell's value.
text string The cell's text.
cellStyle Style The cell's actual value.
zoomFactor number The current sheet's zoom factor.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

number

Returns the cell's width that can be used to handle the column's automatic fit.

Inherited from

Base.getAutoFitWidth


getEditorValue

getEditorValue(editorContext, context?): any

Gets the editor's value.

Parameters

Name Type Description
editorContext HTMLElement The DOM element that was created by the createEditorElement method.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

any

Returns the editor's value.

Inherited from

Base.getEditorValue


getHitInfo

getHitInfo(x, y, cellStyle, cellRect, context?): IHitTestCellTypeHitInfo

Gets the cell type's hit information.

Parameters

Name Type Description
x number x-coordinate of pointer's current location relative to the canvas.
y number y-coordinate of pointer's current location relative to the canvas.
cellStyle Style The current cell's actual style.
cellRect Rect The current cell's layout information.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

IHitTestCellTypeHitInfo

Returns an object that contains the x, y, row, col, cellRect, and sheetArea parameters, and a value to indicate isReservedLocation. isReservedLocation is true if the hit test is in a special area that the cell type needs to handle; otherwise, false.

Inherited from

Base.getHitInfo


isEditingValueChanged

isEditingValueChanged(oldValue, newValue, context?): boolean

Whether the editing value has changed.

Parameters

Name Type Description
oldValue any Old editing value.
newValue any New editing value.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

boolean

true if oldValue equals newValue; otherwise, false.

Inherited from

Base.isEditingValueChanged


isImeAware

isImeAware(context?): boolean

Whether this cell type is aware of IME.

Parameters

Name Type Description
context? any The context associated with the cell type. See the Remarks for more information.

Returns

boolean

true if the cell type is aware of IME; otherwise, false.

Inherited from

Base.isImeAware


isReservedKey

isReservedKey(e, context?): boolean

Whether the cell type handles the keyboard event itself.

Parameters

Name Type Description
e KeyboardEvent The KeyboardEvent.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

boolean

Returns true if the cell type handles the keyboard event itself; otherwise, false.

Inherited from

Base.isReservedKey


marginBottom

marginBottom(value?): any

Gets or sets the button's bottom margin in pixels relative to the cell.

example

//This example creates a button cell and sets its margins.
var cellType = new GC.Spread.Sheets.CellTypes.Button();
cellType.buttonBackColor("#FFFF00");
cellType.text("this is a button");
cellType.marginTop(5).marginRight(8).marginBottom(10).marginLeft(12);
activeSheet.getCell(0, 2).cellType(cellType);
activeSheet.setColumnWidth(2, 120.0,GC.Spread.Sheets.SheetArea.viewport);
activeSheet.setRowHeight(0, 90.0,GC.Spread.Sheets.SheetArea.viewport);

Parameters

Name Type Description
value? number The button's bottom margin relative to the cell.

Returns

any

If no value is set, returns the bottom margin in pixels; otherwise, returns the button cell type.


marginLeft

marginLeft(value?): any

Gets or sets the button's left margin in pixels relative to the cell.

example

//This example creates a button cell and sets its margins.
var cellType = new GC.Spread.Sheets.CellTypes.Button();
cellType.buttonBackColor("#FFFF00");
cellType.text("this is a button");
cellType.marginTop(5).marginRight(8).marginBottom(10).marginLeft(12);
activeSheet.getCell(0, 2).cellType(cellType);
activeSheet.setColumnWidth(2, 120.0,GC.Spread.Sheets.SheetArea.viewport);
activeSheet.setRowHeight(0, 90.0,GC.Spread.Sheets.SheetArea.viewport);

Parameters

Name Type Description
value? number The button's left margin relative to the cell.

Returns

any

If no value is set, returns the left margin in pixels; otherwise, returns the button cell type.


marginRight

marginRight(value?): any

Gets or sets the button's right margin in pixels relative to the cell.

example

//This example creates a button cell and sets its margins.
var cellType = new GC.Spread.Sheets.CellTypes.Button();
cellType.buttonBackColor("#FFFF00");
cellType.text("this is a button");
cellType.marginTop(5).marginRight(8).marginBottom(10).marginLeft(12);
activeSheet.getCell(0, 2).cellType(cellType);
activeSheet.setColumnWidth(2, 120.0,GC.Spread.Sheets.SheetArea.viewport);
activeSheet.setRowHeight(0, 90.0,GC.Spread.Sheets.SheetArea.viewport);

Parameters

Name Type Description
value? number The button's right margin relative to the cell.

Returns

any

If no value is set, returns the right margin in pixels; otherwise, returns the button cell type.


marginTop

marginTop(value?): any

Gets or sets the button's top margin in pixels relative to the cell.

example

//This example creates a button cell and sets its margins.
var cellType = new GC.Spread.Sheets.CellTypes.Button();
cellType.buttonBackColor("#FFFF00");
cellType.text("this is a button");
cellType.marginTop(5).marginRight(8).marginBottom(10).marginLeft(12);
activeSheet.getCell(0, 2).cellType(cellType);
activeSheet.setColumnWidth(2, 120.0,GC.Spread.Sheets.SheetArea.viewport);
activeSheet.setRowHeight(0, 90.0,GC.Spread.Sheets.SheetArea.viewport);

Parameters

Name Type Description
value? number The button's top margin relative to the cell.

Returns

any

If no value is set, returns the top margin in pixels; otherwise, returns the button cell type.


paint

paint(ctx, value, x, y, w, h, style, context?): void

Paints a cell on the canvas.

Parameters

Name Type Description
ctx CanvasRenderingContext2D The canvas's two-dimensional context.
value any The cell's value.
x number x-coordinate relative to the canvas.
y number y-coordinate relative to the canvas.
w number The cell's width.
h number The cell's height.
style Style The cell's actual style.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

void

Inherited from

Base.paint


paintContent

paintContent(ctx, value, x, y, w, h, style, context?): void

Paints the cell content area on the canvas.

Parameters

Name Type Description
ctx CanvasRenderingContext2D The canvas's two-dimensional context.
value any The cell's value.
x number x-coordinate relative to the canvas.
y number y-coordinate relative to the canvas.
w number The cell content area's width.
h number The cell content area's height.
style Style The cell's actual style.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

void

Inherited from

Base.paintContent


parse

parse(text, formatStr, context?): any

Parses the text with the specified format string to an object.

Parameters

Name Type Description
text string The parse text string.
formatStr string The parse format string.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

any

The parsed object.

Inherited from

Base.parse


processKeyDown

processKeyDown(event, context?): boolean

Processes key down in display mode.

Parameters

Name Type Description
event KeyboardEvent The KeyboardEvent.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

boolean

Returns true if the process is successful; otherwise, false.

Inherited from

Base.processKeyDown


processKeyUp

processKeyUp(event, context?): boolean

Processes key up in display mode.

Parameters

Name Type Description
event KeyboardEvent The KeyboardEvent.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

boolean

Returns true if the process is successful; otherwise, false.

Inherited from

Base.processKeyUp


processMouseDown

processMouseDown(hitInfo): boolean

Processes mouse down in display mode.

Parameters

Name Type Description
hitInfo IHitTestCellTypeHitInfo The hit test information returned by the getHitInfo method. See the Remarks for more information.

Returns

boolean

Returns true if the process is successful; otherwise, false.

Inherited from

Base.processMouseDown


processMouseEnter

processMouseEnter(hitInfo): boolean

Processes mouse enter in display mode.

Parameters

Name Type Description
hitInfo IHitTestCellTypeHitInfo The hit test information returned by the getHitInfo method. See the Remarks for more information.

Returns

boolean

Returns true if the process is successful; otherwise, false.

Inherited from

Base.processMouseEnter


processMouseLeave

processMouseLeave(hitInfo): boolean

Processes mouse leave in display mode.

Parameters

Name Type Description
hitInfo IHitTestCellTypeHitInfo The hit test information returned by the getHitInfo method. See the Remarks for more information.

Returns

boolean

Returns true if the process is successful; otherwise, false.

Inherited from

Base.processMouseLeave


processMouseMove

processMouseMove(hitInfo): boolean

Processes mouse move in display mode.

Parameters

Name Type Description
hitInfo IHitTestCellTypeHitInfo The hit test information returned by the getHitInfo method. See the Remarks for more information.

Returns

boolean

Returns true if the process is successful; otherwise, false.

Inherited from

Base.processMouseMove


processMouseUp

processMouseUp(hitInfo): boolean

Processes mouse up in display mode.

Parameters

Name Type Description
hitInfo IHitTestCellTypeHitInfo The hit test information returned by the getHitInfo method. See the Remarks for more information.

Returns

boolean

Returns true if the process is successful; otherwise, false.

Inherited from

Base.processMouseUp


selectAll

selectAll(editorContext, context?): void

Selects all the text in the editor DOM element.

Parameters

Name Type Description
editorContext HTMLElement The DOM element that was created by the createEditorElement method.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

void

Inherited from

Base.selectAll


setEditorValue

setEditorValue(editorContext, value, context?): void

Sets the editor's value.

Parameters

Name Type Description
editorContext HTMLElement The DOM element that was created by the createEditorElement method.
value any The value returned from the active cell.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

void

Inherited from

Base.setEditorValue


text

text(value?): any

Gets or sets the button's content.

example

//This example creates a button cell.
var cellType = new GC.Spread.Sheets.CellTypes.Button();
cellType.buttonBackColor("#FFFF00");
cellType.text("this is a button");
activeSheet.getCell(0, 2).cellType(cellType);

Parameters

Name Type Description
value? string The button's content.

Returns

any

If no value is set, returns the content; otherwise, returns the button cell type.


toJSON

toJSON(): any

Saves the object state to a JSON string.

Returns

any

The cell type data.

Inherited from

Base.toJSON


updateEditor

updateEditor(editorContext, cellStyle, cellRect, context?): Rect

Updates the editor's size.

Parameters

Name Type Description
editorContext HTMLElement The DOM element that was created by the createEditorElement method.
cellStyle Style The cell's actual style.
cellRect Rect The cell's layout information.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

Rect

Returns the new size for cell wrapper element, it should contain two properties 'width' and 'height'.

Inherited from

Base.updateEditor


updateEditorContainer

updateEditorContainer(editorContext, editorBounds, cellStyle): void

Updates the cell wrapper element size.

Parameters

Name Type Description
editorContext HTMLElement The DOM element that was created by the createEditorElement method.
editorBounds Rect The cell wrapper element's new size.
cellStyle Style The cell's actual style.

Returns

void

Inherited from

Base.updateEditorContainer


updateImeMode

updateImeMode(editorContext, imeMode, context?): void

Updates the editor's ime-mode.

Parameters

Name Type Description
editorContext HTMLElement The DOM element that was created by the createEditorElement method.
imeMode ImeMode The ime-mode from cell's actual style.
context? any The context associated with the cell type. See the Remarks for more information.

Returns

void

Inherited from

Base.updateImeMode