Tooltip

by DivineTraveller
Do you want your objects to have a pop-up description?
ID:107732
 
Keywords: koil, tooltip
As much as I dislike taking up space on the front page with my two posts, I didn't want to lose all my motivation tonight, so I figured I'd bundle this up as a demo, seen as Koil doesn't seem to mind.
[edit: oh, hey, it doesn't take up space on the front page. yay!]

A bit more about the tooltips: they're very extensible. You can control whether they fade out, how big they are (well, yeah), and then control them right down to the CSS (sandbox, what is css?) that they contain. It's pretty cool!

The tooltips were mentioned in my previous post, related to my upcoming game, Mantra.

A few people had asked me via several mediums if I would release it, and I guess, the only reason I'd held it back was because of Koil. Go on, thank Koil now. :P
Very neat.

However, there seems to be quite a delay before the tooltips appear. I see some sleep(10)s in the code which probably explain the delay, what are they for?

Also, is it essential to call update_mouse() each time? You can use the output() proc to invoke JavaScript functions so you can output the JavaScript containing the coordinate() function to the browser once then merely invoke it when you need to get the coordinates.
The sleep(10) is something I should probably have left customizable, but it has to be at least a sleep(1), otherwise JavaScript didn't seem to give me coordinates back in time.

When you mention it that way, it isn't really necessary to output it each and every time. I wasn't aware we could just invoke a JavaScript function from the browser, though -- I must have missed it in the release notes. I'll look into that.
I double checked why the sleeps were in there, and I lied, it wasn't not-giving me the coordinates, it just spawned windows too quickly.
Looking at it more, I'm not sure if you can get away without re-sending the HTML. It looks like you need an event to fire to get the screenX and screenY. I'm not sure if there is another event (instead of onload) that you can use to capture the coordinates as needed or if you can trick JS into triggering an event.
it took like 5 seconds for any tooltip to appear for me. like, i could scroll my mouse over one of the objects for half a second and then move my mouse off the object, and then 5 seconds later the tooltip would pop up, wait, and fade away
The tool tip doesn't appear.
@Zaole, it does take a while (Koil told me this would happen as well), plus I have a two second buffer built in to that demo, and it could get cut down to about .5 sec, or less.

@Darker, you'll have to elaborate.