 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
compuboy_r
Joined: 04 May 2004 Posts: 68
|
Posted: Thu Sep 16, 2004 6:31 pm Post subject: ToolTip in GUI |
|
|
How about having a Tooltip associated with A Gui Control so that it is displayed when mouse pointer rests on that control.
compuboy_r |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Thu Sep 16, 2004 7:25 pm Post subject: |
|
|
Nice idea; I've noted it.
You probably already know that you could do this already (just not as easily) with a combination of SetTimer, MouseGetPos, and ToolTip. |
|
| Back to top |
|
 |
Stefan
Joined: 30 Jul 2004 Posts: 74 Location: Deutschland (sorry for my english)
|
Posted: Thu Oct 21, 2004 10:34 am Post subject: Re: ToolTip in GUI |
|
|
| compuboy_r wrote: | How about having a Tooltip associated with A Gui Control so that it is displayed when mouse pointer rests on that control.
compuboy_r |
Iam just search the forum for that feature
because i missed it too.
I think about smtg like this:
Gui, Add, Button, x27 y68 w70 h20, Start
Gui, Add, ToolTip, x27 y68, Text to display in tool tip, 5 (seconds to display this tool tip)
Gui, Show, ToolTip, Text to display in tool tip for hole GUI, 2 (sec), 1 (1= show only first time the GUI is started)
thanks _________________ Stefan
This post was created with the kindly help of http://dict.leo.org/ and remember: “Allways look on the bright side of Life” |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Thu Oct 21, 2004 11:05 am Post subject: |
|
|
That's a good idea for the syntax, I'll consider using it when the time comes.
Until this gets done, try something like like the following, which I just tested: | Code: | SetTimer, ShowToolTip, 100
...
return
ShowToolTip:
IfWinNotActive, GUI Demo
{
ToolTip ; Hide the tip.
return
}
; Otherwise:
MouseGetPos,,,, MouseControl
if MouseControl = Edit1
ToolTip Enter your name.
else if MouseControl = Edit2
ToolTip Enter your complete address.
else if MouseControl = Button8
ToolTip Press OK to save your changes.
else ; No control under mouse or no tooltip defined for it.
ToolTip ; Hide the tip.
return |
It's a little non-traditional because the tooltip pops up immediately. |
|
| Back to top |
|
 |
beardboy
Joined: 02 Mar 2004 Posts: 444 Location: SLC, Utah
|
Posted: Sun Feb 27, 2005 7:20 pm Post subject: |
|
|
Is this still on the Planned Features list?
thanks,
beardboy |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Sun Feb 27, 2005 9:56 pm Post subject: |
|
|
| It is, but at this rate it will be a long time unless someone else does it sooner. Perhaps the workaround above or something similar will help in the meantime. |
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Sun Sep 11, 2005 9:31 pm Post subject: |
|
|
Hi,
actually it's not possible to make tooltips for dynamic GUIs because MouseGetPos only retrieves the general control-name and not the assigned variable. Maybe just enhancing MouseGetPos could make it easy to create a short subroutine which displays tooltips form an array. _________________ Tekl |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Mon Sep 12, 2005 12:26 pm Post subject: |
|
|
| Thanks. I think an option can be added for that. |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2436
|
Posted: Tue Sep 13, 2005 5:48 am Post subject: Re: ToolTip in GUI |
|
|
| compuboy_r wrote: | How about having a Tooltip associated with A Gui Control so that it is displayed when mouse pointer rests on that control.
compuboy_r |
| Code: | ; OnMessage ToolTip Example
; Corrupt - Sept 13, 2005
; Version 0.2
Gui, Add, Text,, Move your mouse anywhere in this window.
Gui, Add, Edit, w200 vMyEdit
Gui, Add, Edit, w200 vMyEdit2
Gui, Add, Button,, Test Button1
Gui, Add, Button,, Test Button2
Gui, Add, Text,, This is a test
Gui, Add, Text,, We are testing to see if we can add tooltips to `nan AHK GUI window by using an OnMessage event.
Gui, Show,, test
WinSet, Transparent, 200, test
SetToolTips()
OnMessage(0x200, "WM_MOUSEMOVE")
Return
WM_MOUSEMOVE(wParam, lParam)
{
Global
MouseGetPos,tt_x,tt_y,, tt_ThisControl
If (tt_x <> tt_xx Or tt_yy <> tt_y)
ToolTip
CurrentTip := tt_%tt_ThisControl%
If (tt_TipShown <> CurrentTip)
{
ToolTip
SetTimer, ToolTipStart, %tt_StartDelay%
}
MouseGetPos,tt_xx,tt_yy,, tt_ThisControl
}
SetToolTips()
{
Global
; Tooltips - User defined
tt_Static1 := "This is Text control #1"
tt_Static2 := "Hi, I'm Text control #2"
tt_Static3 := "It looks like the script passed the test. Text control #3"
tt_Button1 := "Button1"
tt_Button2 := "Button2"
tt_Edit1 := "Edit control #1"
tt_Edit2 := "Edit #2"
; ToolTip delays
tt_StartDelay := 1000
tt_Timeout := 4000
}
ToolTipStart:
MouseGetPos,tt_Chkx,tt_Chky,, tt_ChkControl
If (tt_ChkControl = tt_ThisControl)
If (tt_Chkx = tt_x)
If (tt_Chky = tt_y)
{
ToolTip, %CurrentTip%
tt_TipShown := CurrentTip
SetTimer, ToolTipTimeout, %tt_Timeout%
}
SetTimer, ToolTipStart, Off
Return
ToolTipTimeout:
ToolTip
SetTimer, ToolTipTimeout, Off
Return
GuiClose:
ExitApp
|
|
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Tue Sep 13, 2005 1:18 pm Post subject: |
|
|
| Great example for having a custom tooltip for each control! |
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Tue Sep 13, 2005 1:22 pm Post subject: |
|
|
Hi,
is there a way the get the controlname of these generic names with the actual version of AHK? _________________ Tekl |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Tue Sep 13, 2005 2:12 pm Post subject: |
|
|
| An OnMessage function such as WM_MOUSEMOVE() can use the variable A_GuiControl. In this case, it contains the control's GUI variable name. |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2436
|
Posted: Wed Sep 14, 2005 2:27 am Post subject: |
|
|
| Chris wrote: | | Great example for having a custom tooltip for each control! | Thanks . |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2436
|
Posted: Wed Sep 14, 2005 5:14 am Post subject: |
|
|
Here it is as an include file instead . I wasn't aware that timers could be buried in functions...
| Code: | ; ********************************************
; cor_ToolTipLib.ahk
; ********************************************
; Purpose: Include Library for adding ToolTips to multiple controls
; Author: Corrupt
; Version: 0.3
; Last Modified: Sept. 14, 2005
; ********************************************
/*
To set the Tooltips:
- Use tt_ + ClassNN of the control for the variable name
- These variables can be set anywhere in the code to enable/disable/modify the tooltip used
Example: tt_Button1 := "This is the ToolTip associated with Button1"
To Activate this library the following lines are needed somewhere in the script's code:
OnMessage(0x200, "WM_MOUSEMOVE")
WM_MOUSEMOVE(wParam, lParam)
{
ShowToolTips()
}
- These lines have been left commented out by default in case this OnMessage value is used
elsewhere in a script. If this is the case just add ShowToolTips() to the beginning of your
WM_MOUSEMOVE (or related) function.
- These two variables can be set in a script to modify the default delay times (in milliseconds):
tt_StartDelay, tt_Timeout
*/
; ********************************************
; Code Start
; ********************************************
; Set Default delay times
tt_StartDelay := 1000
tt_Timeout := 4000
ShowTooltips()
{
Global
MouseGetPos,tt_x,tt_y,, tt_ThisControl
If (tt_x <> tt_xx Or tt_yy <> tt_y)
ToolTip
CurrentTip := tt_%tt_ThisControl%
If (tt_TipShown <> CurrentTip)
{
ToolTip
SetTimer, ToolTipStart, %tt_StartDelay%
}
MouseGetPos,tt_xx,tt_yy,, tt_ThisControl
Return
; Display Tooltip
ToolTipStart:
MouseGetPos,tt_Chkx,tt_Chky,, tt_ChkControl
If (tt_ChkControl = tt_ThisControl)
If (tt_Chkx = tt_x)
If (tt_Chky = tt_y)
{
ToolTip, %CurrentTip%
tt_TipShown := CurrentTip
SetTimer, ToolTipTimeout, %tt_Timeout%
}
SetTimer, ToolTipStart, Off
Return
; Remove ToolTip Display
ToolTipTimeout:
ToolTip
SetTimer, ToolTipTimeout, Off
Return
}
|
Test script: | Code: | ; OnMessage ToolTip Example
; Corrupt - Sept. 14, 2005
; Version 0.3
#Include cor_ToolTipLib.ahk
; Create GUI
Gui, Add, Text,, Move your mouse anywhere in this window.
Gui, Add, Edit, w200 vMyEdit
Gui, Add, Edit, w200 vMyEdit2
Gui, Add, Button,, Test Button1
Gui, Add, Button,, Test Button2
Gui, Add, Text,, This is a test
Gui, Add, Text,, We are testing to see if we can add tooltips to `nan AHK GUI window by using an OnMessage event.
Gui, Show,, test
WinSet, Transparent, 200, test
; Set Tooltip values
tt_Static1 := "This is Text control #1"
tt_Static2 := "Hi, I'm Text control #2"
tt_Static3 := "It looks like the script passed the test. Text control #3"
tt_Button1 := "This is Button1. `nButton2 does not have an associated ToolTip."
tt_Edit1 := "Edit1"
tt_Edit2 := "Edit2"
; Activate Tooltips
OnMessage(0x200, "WM_MOUSEMOVE")
Return
WM_MOUSEMOVE(wParam, lParam)
{
ShowToolTips()
}
GuiClose:
ExitApp |
|
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Wed Sep 14, 2005 3:51 pm Post subject: |
|
|
Thanks for the self-contained version. I think the biggest single improvement to this is Tekl's idea to have it use the GUI's variable name/text rather than the ClassNN. However, I'm not entirely sure it's feasible.
| corrupt wrote: | I wasn't aware that timers could be buried in functions...  | Neither was I, but I'm glad it works. I'll check the design to ensure there are no unforeseen side-effects. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|