TinyMCE:API/tinymce.ui.Button/Button

From Moxiecode Documentation Wiki

Jump to: navigation, search

Contents

Constructor: Button

Summary

Constructs a new Button instance. You should normally not use this method since the ControlManager is a factory class for all UI controls and that should be used instead. It will create a button instance and initialize it with common settings.

Syntax

Button(<string> id, <Object> s)

Parameters

id
Control id.
s
Optional settings collection.

Settings

onclick
Function to execute when the button is clicked. If this is set, then cmd is ignored.
cmd
Command to execute when the button is clicked. (Only available when created using the ControlManager). If this is set and onclick is not set, then a button click invokes execCommand() with this as the command parameter and the value setting as the value parameter.
class
Class to add as the icon for the button. Remember class is an reserved word in JavaScript so you need to add quotes around it. See the example below.
image
Image to add as the icon for the button.
label
If you don't wanna image just use the text
scope
Function call scope for the onclick function.
title
Title to add as the title attribute for the button.
ui
The ui parameter to use when invoking execCommand on button click, if cmd is set and onclick is not set.
value
The value parameter to use when invoking execCommand on button click, if cmd is set and onclick is not set.

Example

var ctrl = editor.controlManager.createButton('mybutton', {
   title : 'My button',
   'class' : 'mybutton',
   onclick : function() {
       editor.execCommand('Bold');
   }
});
Personal tools