Button class
📖 Description
The Button
class defines a button control for the Tripetto builder. It is derived from the Control
class.
📺 Preview
🆕 constructor
Creates a new Button
instance.
Signature
constructor(
label: string,
type?: "normal" | "accept" | "warning" | "cancel",
style?: IButtonStyle
): Button
Parameters
Name | Type | Optional | Description |
---|---|---|---|
label | string | No | Specifies the label for the button. |
type | "normal" | "accept" | "warning" | "cancel" | Yes | Specifies the button type. |
style | IButtonStyle | Yes | Specifies the button style (when omitted the default global style will be used). |
Return value
Returns a reference to the new Button
instance.
📌 Statics
🏷️ style
Contains the global default style for the button control.
Type
🗃️ Fields
🏷️ buttonType
Sets or retrieves the button type.
Type
"normal" | "accept" | "warning" | "cancel"
🏷️ hasFocus
Retrieves if the control has input focus.
Type
boolean
🏷️ isDisabled
Sets or retrieves if the control is disabled.
Type
boolean
🏷️ isObservable
Retrieves if the control is observable.
Type
boolean
🏷️ isVisible
Sets or retrieves the visibility of the control.
Type
boolean
🏷️ style
Contains the style for the button control.
Type
▶️ Methods
🔧 blur
Blurs the focus of the control.
Signature
blur(): void
🔧 disable
Disables the control.
Signature
disable(): this
Return value
Returns a reference to the Button
instance to allow chaining.
🔧 disabled
Specifies the state of the control.
Signature
disabled(disabled?: boolean): this
Parameters
Name | Type | Optional | Description |
---|---|---|---|
disabled | boolean | Yes | Specifies if the control is disabled (default is true ). |
Return value
Returns a reference to the Button
instance to allow chaining.
🔧 enable
Enables the control.
Signature
enable(): this
Return value
Returns a reference to the Button
instance to allow chaining.
🔧 focus
Sets the focus to the control.
Signature
focus(): boolean
Return value
Returns true
if the focus is set.
🔧 hide
Hides the control.
Signature
hide(): this
Return value
Returns a reference to the Button
instance to allow chaining.
🔧 indent
Enables control indentation. This can only be set during construction.
Signature
indent(size: number): this
Parameters
Name | Type | Optional | Description |
---|---|---|---|
size | number | No | Specifies the indent size in pixels. |
Return value
Returns a reference to the Button
instance to allow chaining.
🔧 label
Sets the label for the control.
Signature
label(label: string): this
Parameters
Name | Type | Optional | Description |
---|---|---|---|
label | string | No | Specifies the control label. |
Return value
Returns a reference to the Button
instance to allow chaining.
🔧 markdown
Specifies if the label should support markdown formatting.
Signature
markdown(options?: IMarkdownOptions): this
Parameters
Name | Type | Optional | Description |
---|---|---|---|
options | IMarkdownOptions | Yes | Specifies the markdown options. |
Return value
Returns a reference to the Button
instance to allow chaining.
🔧 on
Specifies the tap function.
Signature
on(fn: (button: Button) => void): this
Parameters
Name | Type | Optional | Description |
---|---|---|---|
fn | (button: Button ) => void | No | Specifies the tap function. |
Return value
Returns a reference to the Button
instance to allow chaining.
🔧 show
Shows the control.
Signature
show(): this
Return value
Returns a reference to the Button
instance to allow chaining.
🔧 type
Sets the button type.
Signature
type(type: "normal" | "accept" | "warning" | "cancel"): this
Parameters
Name | Type | Optional | Description |
---|---|---|---|
type | "normal" | "accept" | "warning" | "cancel" | No | Specifies the button type. |
Return value
Returns a reference to the Button
instance to allow chaining.
🔧 url
Specifies an URL for the button.
Signature
url(link?: string, target?: "blank" | "self"): this
Parameters
Name | Type | Optional | Description |
---|---|---|---|
link | string | Yes | Specifies the URL. |
target | "blank" | "self" | Yes | Specifies the target for the URL. |
Return value
Returns a reference to the Button
instance to allow chaining.
🔧 visible
Specifies the visibility of the control.
Signature
visible(visible?: boolean): this
Parameters
Name | Type | Optional | Description |
---|---|---|---|
visible | boolean | Yes | Specifies if the control is visible (default is true ). |
Return value
Returns a reference to the Button
instance to allow chaining.
🔧 width
Sets the width of the control.
Signature
width(width: number | "auto" | "full"): this
Parameters
Name | Type | Optional | Description |
---|---|---|---|
width | number | "auto" | "full" | No | Specifies the control width in pixels or sets the width to auto or full . |
Return value
Returns a reference to the Button
instance to allow chaining.
⛓️ Interfaces
🔗 IButtonStyle
Describes the interface for the button styles.
Type declaration
interface IButtonStyle {
/* Button appearance. */
appearance?: IStyles;
/* Button fused with form. */
fused?: IStyles;
/* Button disabled. */
disabled?: IStyles;
/* Button focus. */
focus?: IStyles;
/* Button hover. */
hover?: IStyles;
/* Button tapped. */
tap?: IStyles;
/* Normal button. */
normal?: {
/* Button appearance. */
appearance?: IStyles;
/* Button focus. */
focus?: IStyles;
/* Button hover. */
hover?: IStyles;
/* Button tapped. */
tap?: IStyles;
};
/* Accept button. */
accept?: {
/* Button appearance. */
appearance?: IStyles;
/* Button focus. */
focus?: IStyles;
/* Button hover. */
hover?: IStyles;
/* Button tapped. */
tap?: IStyles;
};
/* Warning button. */
warning?: {
/* Button appearance. */
appearance?: IStyles;
/* Button focus. */
focus?: IStyles;
/* Button hover. */
hover?: IStyles;
/* Button tapped. */
tap?: IStyles;
};
/* Cancel button. */
cancel?: {
/* Button appearance. */
appearance?: IStyles;
/* Button focus. */
focus?: IStyles;
/* Button hover. */
hover?: IStyles;
/* Button tapped. */
tap?: IStyles;
};
}