Tooltips

Tooltips


Tooltips are useful if you wish to give a quick description about the item, it's incredibly simple to add tooltips to your menu system.

If you make a MenuItem like so:

var open = new MenuItem("Open","open.html");

But you wanted it to attach a tooltip, you just add an extra String parameter in like this:

var open = new MenuItem("Open","open.html","I Am the tooltip!");

For a MenuButton that you've defined like:

var home = new MenuButton("Home","index.html");

And you want to attach a tooltip, the same applies, you add an extra String parameter in

var home = new MenuButton("Home","index.html","Goto the home page (tooltip)");

If you're adding a Menu to a MenuBar, on the definition of the Menu you add the extra String parameter in on the end aswell

So if you define a File Menu like:

var fileMenu = new Menu("File");

You can add a tooltip by adding a parameter in on the end:

var fileMenu = new Menu("File","This is the tooltip");

If you're working with images it's exactly the same for all objects. An example of MenuButton:

var homeImage = new image("home.gif");
var homeButton = new MenuButton(homeImage,"index.html","Click me to goto the main page");

That's tooltips covered, onto Lesson 4b Which shows you how to add separators into your Menus.