In Amibroker we can do anything, right? Well, I thought so and gave it a try.
Here is a prototype GuiButton() that returns hover information. Please tell me what is wrong with this approach.
It seems to work fine if you do not mover your mouse too fast (perfectly OK for popups and the like). You can make the borders a little wider to obtain better hover detection.
I surround the GuiButton with a small gfx border and reduce the GuiButton by the same amount. Since, when you hover over a GuiButton the gfx values are frozen you can use this to detect when you enter the button area. Sorry I don’t have the time right now to polish up this code but hopefully some of the experts on this list can suggest improvements. For example why I had to fudge the x-y values to fit the overlay.
function xGuiButton( Label, ButtonID, x1, y1, width, height, notifyflags )
{
global border, cx, cy;
GfxSelectPen( colorred, border );
GfxSelectSolidBrush( colorLightGrey );
x2 = X1 + width;
y2 = y1 + height;
GfxMoveTo( x1, y1 );
GfxLineTo( x2, y1 );
GfxLineTo( x2, y2 );
GfxLineTo( x1, y2 );
GfxLineTo( x1, y1 );
GuiButton( "TEST", TestID = 1, x1 + border, y1 + border, width - border - 1, height - border - 1, 7 );
OverButton = cx >= x1 AND cx <= x2 AND cy >= y1 AND cy <= y2;
return Overbutton;
}
RequestMouseMoveRefresh();
width = 200;
height = 50;
Border = 1;
x1 = 50;
y1 = 100;
cx = GetCursorXPosition( 1 );
cy = GetCursorYPosition( 1 );
Hover = xGuiButton( "TEST", TestID = 1, x1 + border, y1 + border, width - border, height - border, 7 );
GuiSetColors( 1, 1, Border,
/* Text, Back, Border */
colorblack, colorlightgrey, colorblack,
colorblack, colorbrightGreen, colorblack, // Select
colorwhite, colorblue, colorblack ); // Hover
if( Hover ) GuiSetText( "HOVER", TestID );
Title =
"CursorXposition = " + cx + "\n" +
"CursorYPosition = " + cy + "\n" +
" Hover = " + Hover;