home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2004 February
/
PCWorld_2004-02_cd.bin
/
software
/
topware
/
winamp5
/
winamp50beta2.exe
/
$_14327_
/
tooltips.m
< prev
next >
Wrap
Text File
|
2002-11-26
|
971b
|
35 lines
#include <lib/std.mi>
Global Group tipGroup;
Global Text tipText;
System.onScriptLoaded() {
tipGroup = getScriptGroup();
tipText = tipGroup.getObject("tooltip.text");
}
// When text is changed, resize the group accordingly and make sure it's fully visible
tipText.onTextChanged(String newtext) {
int x = getMousePosX();
int y = getMousePosY()-tipGroup.getHeight(); // move above mouse by default
int vpleft = getViewportLeft();
int vptop = getViewportTop();
int vpright = vpleft+getViewportWidth();
int vpbottom = vptop+getViewportHeight();
int w = getTextWidth()+20;
int h = tipGroup.getHeight();
if (x + w > vpright) x = vpright - w;
if (x < vpleft) x = vpleft;
if (x + w > vpright) { w = vpright-vpleft-64; x = 32; }
if (y + h > vpbottom) y = vpbottom - h;
if (y < vptop) y = vptop + 32; // avoid mouse
if (y + h > vpbottom) { h = vpbottom-vptop-64; y = 32; }
tipGroup.resize(x, y, w, h);
}