Tooltips

BlitzPlus Forums/BlitzPlus Programming/Tooltips

plash(Posted 2006) [#1]
Could of sworn I already created this topic...

Anyways, is there some userlib out there that will allow you to create tooltips for gadgets?


Andres(Posted 2006) [#2]
Function CreateTooltip(msg$, x%, y%)
	MouseXSpeed():MouseYSpeed()
	buffer% = GraphicsBuffer()
	SetBuffer DesktopBuffer()
	Local window = CreateWindow("", x%, y%, StringWidth(msg$) + 6, 20, Desktop(), 16)
	Local canvas = CreateCanvas(0, 0, ClientWidth(window), ClientHeight(window), window)
	SetBuffer CanvasBuffer(canvas)
	While Abs(MouseXSpeed() + MouseYSpeed()) = 0
		Color 255, 255, 225
		Rect 1, 1, ClientWidth(canvas) - 2, ClientHeight(canvas) - 2
		Color 0, 0, 0
		Text 3, ClientHeight(canvas) / 2, msg$, False, True
		FlipCanvas canvas
	Wend
	FreeGadget window
	If buffer% SetBuffer buffer% Else SetBuffer DesktopBuffer()
End Function



plash(Posted 2006) [#3]
I was looking more towards a fully setup system to check if the cursor was over a gadget, or a defined area.. But I guess I can just modify this..


Andres(Posted 2006) [#4]
I know that toolbar's have builtin tooltips, but haven't seen it elsewhere.


plash(Posted 2006) [#5]
I did this under 2 hours. Fully functional :)

Tooltip Example.bb


Tooltips.bb



Andres(Posted 2006) [#6]
Very good, but sad that the main window blinks


plash(Posted 2006) [#7]
Yeah, I'll have to come up with a way to do it without using a window.


Andres(Posted 2006) [#8]
you can try drawing directly to DesktopBuffer() and before you draw there anything you'll copy the background of it and when you want to remove it then you'll just draw the background on the tooltip.


plash(Posted 2006) [#9]
Yeah I figured that would be the best way to go, I'll probably come up with another version of it sometime later next week.


plash(Posted 2006) [#10]
Voila!

Tooltips.bb


Example.bb



Andres(Posted 2006) [#11]
Super! You should add it to code archives :)


plash(Posted 2006) [#12]
I shall :)