Using JavaScript in HomeSite 4.0, Part II: Manipulating Toolbars, Part II | WebReference

Using JavaScript in HomeSite 4.0, Part II: Manipulating Toolbars, Part II


Using JavaScript in HomeSite 4.0, Part II

Manipulating Toolbars, Part II

AddAppToolbutton(toolbarName, executablePath, commandLineArg, toolTip)Boolean

Adds a button to an existing toolbar (toolbarName). When clicking the button, the given executable (executeablePath) will run. The commandLine argument specify the command line to call the application with. The toolTip argument specifies a short tip that shows up when the mouse is over the button. The following line of code adds an Internet Explorer button to the linkbot toolbar:


app.AddAppToolbutton("linkbot", "C:\\Program Files\\Internet
Explorer\\IEXPLORE.EXE", "U:\\Yehuda\\column49", "Internet Explorer")

Watch for the new button on the linkbot toolbar. The tooltip shows "Internet Explorer", and when invoked, the Internet Explorer sets its location to the given folder U:\Yehuda\Column49. The command line in this particular case includes just the default location. If an empty string is passed instead, the Internet Explorer starts at the default home page. Returns a true value when successful, a false value otherwise. Does not duplicate existing buttons with the same executable path and the same command line.

AddTagToolbutton(toolbarName, tagStart, tagEnd, toolTip, caption, imageFile)Boolean

Adds a button to a given toolbar (toolbarName) for adding a pair of tags to the current active file. The tag pair includes an opening string (tagStart) and a closing string (tagEnd). The button displays a tip message when passing over it with the mouse (toolTip), and has the appearance of the the specified two-letter caption (caption) overlayed on top of the image specified by imageFile. Here is an example:


app.AddTagToolbutton("linkbot", "", "", "Yehuda Tag", "YS",
"C:\\WINDOWS\\Waves.bmp");

You can see that the linkbot toolbar has a new button. Clicking it inserts the specified tag pair into the active document. This method returns a true value if successful, a false value otherwise. A false value is returned if the specified toolbar is not found. A true value is returned if the button already exists (the button is not duplicated).

AddScriptToolbutton(toolbarName, scriptFile, toolTip, caption, imageFile)Boolean

Adds a button to a given toolbar (toolbarName) for running a given JavaScript script (scriptFile). The button displays a tip message when passing over it with the mouse (toolTip), and has the appearance of the the specified two-letter caption (caption) overlaid on top of the image specified by imageFile. For example, the following JavaScript line:


app.AddScriptToolbutton("linkbot", "U:\\Yehuda\\column49\\toolbar.js",
 "Yehuda Tag", "YS", "C:\\WINDOWS\\Waves.bmp");

creates a new button on the linkbot toolbar. The button's appearance consists of a caption ("YS") overlaid on top of an image ("C:\\WINDOWS\\Waves.bmp"). It also displays a tooltip ("Yehuda Tag") when the mouse is over the button. When clicking the button, the script "U:\\Yehuda\\column49\\toolbar.js" is run. Here is the script:

var app = Application;
function Main() {
  app.MessageBox("Hello There", "test", 0);
  app = null;
}

A message box pops up when clicking the button. This is just an example script. It can be as complicated as JavaScript can be. The method returns a true value when successful, a false value otherwise. A false value is returned when the given toolbar is not found. A true value is returned if the button already exists (the button is not duplicated).

AddVTMToolbutton(toolbarName, scriptFile, toolTip, caption, imageFile)Boolean

Adds a VTML button. We don't cover VTML in this column.

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

Created: September 27, 1999
Revised: September 27, 1999

URL: http://www.webreference.com/js/column49/toolbars.html