i've just been messing around and i've managed to modify the included tooltips sample to work with images instead of captions. that's working fine.
but now i'm stuck. what i'd like to do is have hover images as well as the tooltips. i just have no idea how to modify the code to do that.
this is what i have so far.....
// Please do not create more than one tooltip in one panel
var g_tooltip = window.CreateTooltip();
var g_down = false;
var btn_down = null;
var cur_btn = null;
// ------------------------------
// Class `SampleButton'
// ------------------------------
function SampleButton(x, y, w, h, func, tiptext, img) {
// 'Constructor' stuff
this.left = x;
this.top = y;
this.w = w;
this.h = h;
this.right = x + w;
this.bottom = y + h;
this.func = func;
this.tiptext = tiptext;
this.img = gdi.image(fb.FoobarPath + "Images\\simples\\" + img + ".png");
//hover image. maybe?
this.img_h = gdi.image(fb.FoobarPath + "Images\\simples\\" + img + "_h.png");
// Estimate whether the coordinate is in this button
this.traceMouse = function (x, y) {
return (this.left < x) && (x < this.right) && (this.top < y) && (y < this.bottom);
}
this.draw = function (gr) {
gr.DrawImage(this.img,this.left, this.top, this.w, this.h, 0, 0, this.w, this.h);
}
this.onClick = function () {
this.func && this.func(x,y);
}
this.onMouseIn = function() {
// Update tooltip text
g_tooltip.Text = this.tiptext;
g_tooltip.Activate();
}
this.onMouseOut = function() {
// Hide tooltip
g_tooltip.Deactivate();
}
}
function buttonsDraw(gr) {
for (i in SampleButtons) {
SampleButtons[i].draw(gr);
}
}
function buttonsTraceMouse(x, y) {
var btn = null;
for (i in SampleButtons) {
if (SampleButtons[i].traceMouse(x, y) && !btn)
btn = SampleButtons[i];
}
return btn;
}
// ------------------------------
// --- APPLICATION START
// ------------------------------
function on_mouse_move(x, y) {
var btn = buttonsTraceMouse(x, y);
if (btn != cur_btn) {
cur_btn && cur_btn.onMouseOut();
btn && btn.onMouseIn();
}
if (btn != btn_down) {
btn_down = null;
}
cur_btn = btn;
}
function on_mouse_lbtn_down(x, y) {
g_down = true;
btn_down = cur_btn;
}
function on_mouse_lbtn_up(x, y) {
if (cur_btn) {
if (btn_down == cur_btn)
cur_btn.onClick(x, y);
}
g_down = false;
}
function on_paint(gr) {
buttonsDraw(gr);
}
function on_playback_new_track() {
var bw = 24;
var bh = 20;
var WshShell = new ActiveXObject("WScript.Shell");
var wiki = fb.TitleFormat("http://en.wikipedia.org/wiki/$replace(%artist%,' ','_')").Eval(true);
var lastfm = fb.TitleFormat("http://www.last.fm/music/$replace(%artist%,' ','+')").Eval(true);
SampleButtons = {
but1: new SampleButton(0,0,bw,bh, function(){fb.RunMainMenuCommand("View/Columns playlist/Activate now playing");}, "Activate now playing","now playing"),
but2: new SampleButton(bw,0,bw,bh, function(){fb.RunContextCommand("Open Containing Folder");}, "Open Containing Folder","open"),
but3: new SampleButton(bw*2,0,bw,bh, function(){WshShell.run(wiki);}, wiki,"wiki"),
but4: new SampleButton(bw*3,0,bw,bh, function(){WshShell.run(lastfm);}, lastfm,"lastfm")
};
CollectGarbage();
}
on_playback_new_track();
// --- APPLICATION END
any ideas?