iModernize - The Profound Logic Software Blog

Profound Pro Tips: Creating Custom ToolTips

Posted by Tim Losee on Mar 26, 2018 3:15:00 PM

Profound Pro Tips is a blog series focused on issues that our support team receives and questions our Profound Logic customers have. Don't see your question/concern in Profound Pro Tips? Please feel free to contact our team or leave us a comment below. 

Customization for any developer can make the difference between creating a functional application or creating an outstanding application. Our support team has received numerous questions on how to customize their tooltip widget, so this week we decided to give you an idea of how easy it is to customize it!

Tooltip pic 1.pngThis is the standard tooltip provided by the tooltip property. Sometimes, this standard icon is not what you are looking for in a tooltip. This blog will show you how easy it is for you to customize your tooltip widget. 

Step 1: What do you want your tooltip to be?

It’s possible to make nearly anything you’d like into a tooltip. Here are some examples:

Tooltip pic 2.png

 


A different or larger image. 

Tooltip pic 3.pngA wrapping Textbox.

Tooltip pic 4.pngA chart or graph!

Tooltip pic 5.pngOr even a combination of options!

Tooltip pic 8.png

Tooltip pic 6.pngFor this example, we will be creating a new image tooltip widget to demonstrate how easy it is to customize. 

Tooltip pic 7.png If you want your image to be hidden, you will need to set the visibility property of the tooltip image widget to hidden. 

**Make sure to give your tooltip image widget an ID (Ex. ttlmg) to make sure and identify which image you are using. 

Step 2: Set up the onmouseover and onmouseout events of the Image Widget.

After selecting the element you would like the tooltip to appear for, navigate to the events section of the properties. You’ll then add the following code to the specified event.

Onmouseover Event:

// Use this to reveal the tooltip element next to the cursor.
// Get tooltip element.
var ttI = getObj("ttImg");

// Make the tooltip element visible.
ttI.style.visibility = "visible";
// Move the tooltip element to 10px right of cursor.
ttI.style.left = getMouseX(event) + 15 + 'px';
// Move the tooltip element to 15px below cursor.
ttI.style.top  = getMouseY(event) + 15 + 'px';

Onmouseout Event:

// Use this if you’d like the tooltip to disappear when the mouse leaves the
// element.
// Get tooltip element.
var ttI = getObj("ttImg");
// Hide the tooltip element.
ttI.style.visibility = "hidden";
// Move the tooltip element off screen.
ttI.style.left = "-150px";

Onmousemove Event: 

// Use this if you want the tooltip to follow the cursor while moving over
// the element.
// Get tooltip element.
var ttI = getObj("ttImg");
// Move the tooltip element to 10px right of cursor.
ttI.style.left = getMouseX(event) + 15 + 'px';

// Move the tooltip element to 15px below cursor.
ttI.style.top  = getMouseY(event) + 15 + 'px';

And you’re done! You can check out how your tooltip turned out using Launch > Launch Preview
 in the Visual Designer!

Extras: Some additional snippet examples.

Same Source, But Bigger – Onmouseover Event:

// Use this if you want the tooltip to get its image source from the element.
// Get tooltip element.
var ttI = getObj("ttImg");
// Set tooltip image source to image source of element.
ttI.src = this.src;
// Scale image to 150px width.
ttI.style.width = 150 + 'px';
// Scale image to 150px height.
ttI.style.height = 150 + 'px';

Layout Tooltips – Overview:

If your tooltip has multiple things in it or you want the tooltip widget to size automatically to the size of a layout, this can be done! Just add your tooltip widget(s) to a Layout widget, give it a unique ID, and then add the code from the example, customizing it as needed. Make sure to remove the Visibility property of any elements inside the tooltip layout so that they will inherit the layout’s visibility. This can be done by right-clicking the property and selecting Remove Property Value.

Learn how to Make Modern Applications That You Will Love With IBM i RPG and Node.js with Profound UI and Profound.js! This on-demand webinar was hosted by Alex Roytman and Liam Allan | Watch the replay today!


 

Topics: RPG Development, Application modernization, IBM i applications, Node.js, Profound.js, IBM i, RPG, AS400 modernization, IBM i Modernization, Agile modernization, iSeries, Legacy Modernization, Profound UI, AS 400, AS_400, Profound Logic

Subscribe to Blog Updates

...and get The 2017 State of IBM i Modernization White Paper FREE!

cover page.png

Recent Posts