Liberty BASIC Community Forum
Liberty BASIC Programming Discussions >> API/DLL >> Tooltips
http://libertybasic.conforums.com/index.cgi?board=api&action=display&num=1517512471

Tooltips
Post by twebb96 on Feb 1st, 2018, 1:14pm

Hi Again all. Is there a way to make tooltips for non tools. I have a series of small bitmaps, displayed in a graphic box. I would like, if possible, that when you hover over an image it would pop up a tooltip with the name of the image. I have already accomplished this with a window popup, but when the tip comes up the main screen changes color because it loses focus. That is really annoying. Thanks in advance. Anton
Re: Tooltips
Post by Rod on Feb 2nd, 2018, 05:51am

There will be other strategies, this relies on a grid of same sized images. If they are of variable size you will need to keep an positional array and check what image you are on.


Code:
    nomainwin
    WindowWidth = 600
    WindowHeight = 600
    UpperLeftX = Int((DisplayWidth - WindowWidth) /2)
    UpperLeftY = Int((DisplayHeight - WindowHeight) /2)
    graphicbox #main.g, 10, 10, 520, 520
    open "Graphicbox Names" for Window as #main
    #main.g "trapclose [quit]"
    #main.g "down ; fill black ; backcolor blue"

    'dummy up some names
    dim name$(25)
    for n= 0 to 25
        name$(n)="Image "+str$(n)
    next

    'draw some dummy images in a grid
    for x= 10 to 500 step 100
        for y = 10 to 500 step 100
            #main.g "place ";x;" ";y;" ; boxfilled ";x+50;" ";y+50
        next
    next

    'take a copy of how it looks
    #main.g "flush one"

    'set up for checking mouse
    #main.g "backcolor black ; color white"
    #main.g "when mouseMove [check]"
    wait

    [check]
    'where is the mouse?
    x=MouseX
    y=MouseY
    'where in the grid?
    xx=int(x/100)
    yy=int(y/100)
    z=xx+5*yy
    'near enough the image?
    if x>xx*100+25 and x<xx*100+75 and y>yy*100+25 and y<yy*100+75 then
        'draw the name
        #main.g "discard ; redraw one"
        #main.g "place ";x;" ";y;" ;\";name$(z)
    else
        'remove any old name and redisplay
        #main.g "discard ; redraw one"
    end if

    wait

    [quit]
    close #main
    end