Page 1 of 1

Add auto-hide timeout for Tooltip

Posted: 20 Feb 2024, 02:03
by william_ahk
Implement an auto-hide timeout parameter so that we don't have to use SetTimer or a custom function like below to hide it. I think it's frequent enough we need to hide the tooltip. This is especially helpful for new users.

Code: Select all

Tip(Text := "", Time := 1500, X?, Y?) {
	Tooltip(Text, X?, Y?, 20)
	SetTimer () => Tooltip(,,,20), -Time
}
My suggestion for the parameter:
ToolTip [Text, X, Y, WhichToolTip-or-Timeout]
WhichToolTip-or-Timeout
Type: Integer
If omitted, it defaults to 1 (the first tooltip). Otherwise, specify a number between 1 and 20 to indicate which tooltip to operate upon when using multiple tooltips simultaneously. If the number is greater than 20, it will be taken as the delay in milliseconds before hiding the tooltip. The tooltip being operated upon will be unnumbered and outside the set of 20 tooltips.

Re: Add auto-hide timeout for Tooltip

Posted: 27 Apr 2024, 01:40
by DataLife
On 4 of my scripts I use tooltips extensively to display what the script is currently doing. Creating a timer and label for each new tooltip is a hassle.

A timeout would so much simplify things.

Re: Add auto-hide timeout for Tooltip

Posted: 27 Apr 2024, 11:10
by byzod

Code: Select all

TimedToolTip(content, life:=0, x?, y?, whichToolTip:=1){
	life := life < 0 ? 0 : life
	ToolTip(content, x?, y?, whichToolTip)
	SetTimer(()=>ToolTip("", , , whichToolTip), -life)
}

Re: Add auto-hide timeout for Tooltip

Posted: 28 Apr 2024, 14:50
by DataLife
byzod wrote:
27 Apr 2024, 11:10

Code: Select all

TimedToolTip(content, life:=0, x?, y?, whichToolTip:=1){
	life := life < 0 ? 0 : life
	ToolTip(content, x?, y?, whichToolTip)
	SetTimer(()=>ToolTip("", , , whichToolTip), -life)
}
Or from the V2 docs...

Code: Select all

ToolTip "Timed ToolTip`nThis will be displayed for 5 seconds."
SetTimer () => ToolTip(), -5000
I need a tooltip timeout for ahk V1. I did't realize I was commenting on the ahk V2 wishlist.

Re: Add auto-hide timeout for Tooltip

Posted: 02 May 2024, 19:21
by lexikos