Control the time a ToolTipText is displayed

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

Control the time a ToolTipText is displayed

Postby elmono_acosta » Thu Jan 27, 2005 12:58 pm

If I have a small text everything is ok. But if I have a larger text it will disapear very quickly, so the user cant read it completly.

How can I control this ?????
elmono_acosta
 
Posts: 41
Joined: Thu Jun 17, 2004 11:52 am

Postby jcompagner » Mon Jan 31, 2005 4:48 pm

thats a system property, i see it defaults to 4 seconds.
And it will be application wide so you can never controll it for one tooltip. So if we would change the dismiss time then it would happen for all tooltips.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby Westy » Wed Feb 02, 2005 6:33 am

I would prefer 5 seconds instead of 4. A minor issue, but the extra second would help.
Westy
 
Posts: 852
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Postby Harjo » Wed Feb 02, 2005 9:50 am

Johan, can you make adjustable as developer preference?
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Postby yekinabud » Tue Dec 25, 2007 3:05 am

Did this ever make it into preferences? It would be handy.
yekinabud
 
Posts: 30
Joined: Wed Dec 05, 2007 10:06 pm

I'd love it too

Postby ellenmeserow » Mon Mar 03, 2008 10:37 pm

Chiming in -- my client just asked for this too...
ellen escarcega (formerly meserow)
meserow design
Servoy 2019 9
MSSQL 2017
Windows AWS Servers
ellenmeserow
 
Posts: 366
Joined: Sat Aug 07, 2004 10:18 pm
Location: Seattle, WA USA

Postby david » Tue Mar 04, 2008 4:03 pm

Until Servoy adds this in, here's a small plugin to control tooltips. Usage:

Code: Select all
// retrieve/set tooltip initial delay (use milliseconds)
var x = plugins.tooltip.delay
plugins.tooltip.delay = 0

// retrieve/set tooltip time until dismiss (use milliseconds)
var y = plugins.tooltip.dismiss
plugins.tooltip.dismiss = 1000
Attachments
tooltip.jar
(2.97 KiB) Downloaded 459 times
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Thanks!

Postby ellenmeserow » Tue Mar 11, 2008 1:40 am

This works great!
ellen escarcega (formerly meserow)
meserow design
Servoy 2019 9
MSSQL 2017
Windows AWS Servers
ellenmeserow
 
Posts: 366
Joined: Sat Aug 07, 2004 10:18 pm
Location: Seattle, WA USA

Re: Control the time a ToolTipText is displayed

Postby Tokajac » Mon Apr 04, 2011 5:12 pm

Hello,

Tooltip control via above plugin works well in Smart Client, but not in WebClient?

Is there any version that works for WebClient also? Where can I find it?
If not, how to implement extension for WebClient?


Regards
Tokajac
 
Posts: 92
Joined: Sun Jan 03, 2010 10:21 pm

Re: Control the time a ToolTipText is displayed

Postby pbakker » Mon Apr 04, 2011 5:43 pm

It's not possible to control this currently in the Web Client.

Please file a feature request for this, so we can investigate this.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: Control the time a ToolTipText is displayed

Postby david » Mon Apr 04, 2011 10:52 pm

Tokajac wrote:Tooltip control via above plugin works well in Smart Client, but not in WebClient?

Is there any version that works for WebClient also? Where can I find it?
If not, how to implement extension for WebClient?


By default, browsers display the title attribute of a dom element as a tooltip. You can modify this default behavior with client-side javascript and almost all javascript libraries (jquery, prototype, YUI, etc) have libraries to do this -- some very advanced.

Servoy also displays tooltips with client-side javascript but instead of writing out title attributes for elements and then manipulating the title attribute it writes out:

Code: Select all
<div style="white-space:nowrap;" class="label" id="sv_46A5EE99_E1E7_495F_A887_F6965D53CE6E" onmouseover="showtip(event, 'Tooltip text here');" onmouseout="hidetip();" tabIndex="-1">Company</div>


The easiest hack then would be to override servoy's client-side javascript functions that deal with the onmouseover and onmouseout events. Here's the code Servoy uses:

Code: Select all
   <script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/      
      var tipTimeout;
      function showtip(e,message)
      {
      var x = 0;
      var y = 0;
      var m;
      if(!e)
      var e = window.event;
      var targetParentWidth = 0;
      var targetParentHeight = 0;
      var src = e.target;   
         if(!src)
      src = e.srcElement;
      if(src.parentNode)
      {
      var positionXY = getXY(src.parentNode);
      var sizeWH = getRootElementSize(src.parentNode);
      targetParentWidth = positionXY[0] + sizeWH[0];
      targetParentHeight = positionXY[1] + sizeWH[1];
      }
      var wWidth = 0, wHeight = 0;
      if( typeof( window.innerWidth ) == 'number' )
      {
       wWidth = window.innerWidth;
      wHeight = window.innerHeight;
      }
      else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
      {
       wWidth = document.documentElement.clientWidth;
      wHeight = document.documentElement.clientHeight;
      }
      else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
      {
       wWidth = document.body.clientWidth;
      wHeight = document.body.clientHeight;
      }
      if(e.pageX || e.pageY)
      {
      x = e.pageX;
      y = e.pageY;
      }
      else
      if(e.clientX || e.clientY)
      {
      x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
      y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
      }
      m = document.getElementById('mktipmsg');
      m.innerHTML = message;
      m.style.display = "block";
      m.style.left = x + 20 + "px";
      m.style.top = y - 4 + "px";
      setTimeout("adjustTooltip("+x+","+targetParentWidth+","+wWidth +","+y+","+targetParentHeight+","+wHeight+");", 0);
      m.style.zIndex = 203;
      tipTimeout = setTimeout("hidetip();", 5000);
      }
      function adjustTooltip(x,targetParentWidth,wWidth,y,targetParentHeight,wHeight)
      {
      m = document.getElementById('mktipmsg');
      var tooltipOffsetWidth = x + 20 + m.offsetWidth;
      if((targetParentWidth < tooltipOffsetWidth || wWidth < tooltipOffsetWidth)&&(x - 20 -m.offsetWidth>=0))
      m.style.left = x - 20 -m.offsetWidth + "px";
      var tooltipOffsetHeight = y - 4 + m.offsetHeight
      if((targetParentHeight < tooltipOffsetHeight || wHeight < tooltipOffsetHeight)&&(y - 4 - m.offsetHeight>=0))
      {
      m.style.top = y - 4 - m.offsetHeight + "px";
      }
      }
      function hidetip()
      {
      clearTimeout(tipTimeout);
      var m;
      m = document.getElementById('mktipmsg');
      m.style.display = "none";
      }   
   /*-->]]>*/</script>


Change the value of 5000 (which is milliseconds) to whatever value you want on this line:
 
Code: Select all
tipTimeout = setTimeout("hidetip();", 5000);


Now you need to insert this code block into the output servoy generates after where Servoy is including the code -- which would be in the header section. A web page will then call your functions instead of Servoy's since they were loaded last.

This is actually quite easy to do by modifying the top level html template Servoy uses to generate all web client pages. It is called "MainPage.html" and it is only accessible via WebDav.

On a Mac (with Servoy open) > Finder app > "Go" menu item > "Connect to Server..." sub-menu item > enter "http://localhost:8080/servoy-webclient/templates/default/".

Now open up "MainPage.html" in your favorite text editor. Paste in the slightly modified javascript block between the closing /body and closing /html tags.

Restart Servoy.

Disclaimer: this is a hack :) However, it's easy to restore to Servoy's default state. Just delete "MainPage.html" and Servoy will regenerate the original file.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: Control the time a ToolTipText is displayed

Postby bobcusick » Wed Apr 06, 2011 7:59 pm

Thanks, David - really great tips!
User avatar
bobcusick
 
Posts: 126
Joined: Mon Jan 12, 2009 9:13 pm

Re: Control the time a ToolTipText is displayed

Postby Jan Aleman » Wed Apr 06, 2011 10:26 pm

david wrote:
Disclaimer: this is a hack :) However, it's easy to restore to Servoy's default state. Just delete "MainPage.html" and Servoy will regenerate the original file.


Great tip. Actually this is not a hack but exactly why the templates are editable.
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Re: Control the time a ToolTipText is displayed

Postby Tokajac » Thu Apr 07, 2011 5:10 pm

Thank you for your solution David! Tested and it works

Further,
tooltips.jar plugin is based on: javax.swing.ToolTipManager
Thinking about integration of WebClient's tooltip control to that plugin...
Incompleteness of WebDav idea is that Servoy has to be restarted for changes to take effect. Need to access programmatically to MainPage.html: can I update MainPage.html and announce the template changes immediately without restarting Servoy?

How to change the tooltips dynamically in WebClient like it's currently possible in Smart Client via the plugin? That's submitted as a feature request


Regards
Tokajac
 
Posts: 92
Joined: Sun Jan 03, 2010 10:21 pm

Re: Control the time a ToolTipText is displayed

Postby danny.richadson » Tue Dec 06, 2011 2:19 pm

You also use inline java code:

Packages.javax.swing.ToolTipManager.sharedInstance().setInitialDelay(<some_delay);
Packages.javax.swing.ToolTipManager.sharedInstance().setDismissDelay(<some_delay);


Regards,

Danny
Danny Richardson
e-mail: info@danson.nl
User avatar
danny.richadson
 
Posts: 30
Joined: Wed Oct 17, 2007 3:46 pm
Location: Netherlands

Next

Return to How To

Who is online

Users browsing this forum: No registered users and 13 guests