AutoHotkey Community

It is currently May 27th, 2012, 7:23 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: June 7th, 2006, 12:30 pm 
Dear Friends,

I think the biggest improvement that could be made to the gui at present would be to enable Tool Tips for the various controls, so that more detailed information could be given on a control's function when hovering over it. Is there any chance? :idea:

Aj


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 7th, 2006, 12:59 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
With a small workaround (OnMessage()) this is already feasible. For an example see my PSPad syntax highlighting install script.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
PostPosted: June 10th, 2006, 12:48 pm 
Thanks for the "tip" toralf, I learned a lot from that neat bit of coding, but I eventually came up with something a little simpler:

Code:
SetTimer, WatchCursor, 1000 ; in atuo-execute section, this updates slowly, but it is better than having a flickering mouse...

WatchCursor:
MouseGetPos, , , , ControlWatch ; var name

IfWinActive, Dictionary
{
If ControlWatch = Button6
ToolTip, enable/disable searching of`nVen. Buddhadatta's Concise Pali English Dictionary
If ControlWatch = Button7
ToolTip, enable/disable searching of`nMonier-Williams' Sanskrit English Dictionary
If ControlWatch <> Button6
If ControlWatch <> Button7
ToolTip, ;
}
return

That's the principle, and it works --- but I still think that Tool Tips for Controls should be implemented as a normal feature of the gui...

Aj


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2006, 6:01 pm 
Offline

Joined: February 13th, 2006, 10:40 pm
Posts: 389
Location: Utah
Heres a nice one that i developed with the help from some other people:

It uses Windows Message 0x200 (WM_MOUSEMOVE) so that everytime the mouse moves the control under the mouse is recorded in %A_GuiControl%, then since we assigned the controls a variable tooltip name we dont have to have a series of else if statements. This creates a very smooth tooltip that disapears instantaneously when you roll off of a control. The KillToolTip function is just in case someone alt-tabs out because then they wouldnt roll of a control, thus destroying the tooltip. 2 problems is that it doesnt work over text, and it does use a little bit of cpu juice. About 20% of my 1.0 ghz when i move the mouse around the gui.

Code:
;first, define all tooltips, they must be the control name followed by "_TT" (or "_tt")
_tt = ;this tooltip appears when "nothing" is below the mouse (except that i commented it out)
button_TT = This button will make your computer self destruct
words_TT = sorry, dont know why this doesnt work
Firstname_tt = Type your first name here.
Lastname_tt = Type your last name here.
Address_tt = Type your address here.
City_tt = Type your city here.
State_tt = Type your two digit state abreviation here.
Zip_tt = Type your 5 digit zip code here.


;whenever the mouse moves, run the function
OnMessage(0x200, "WM_MOUSEMOVE")

gui, add, text, vwords, unfortunately text cannot have a tooltip
gui, add, edit,section w100 vfirstname,
gui, add, edit,x+10 w100 vlastname
gui, add, edit,xs w120 vAddress
gui, add, edit,x+10 w80 vCity
gui, add, edit,x+10 w30 limit2 vState
gui, add, edit,x+10 w50 limit5 vZip
gui, add, button,xm vbutton, THE BUTTON
gui, add, button, vboring, this button does not have a tooltip becuase "boring_tt" was not defined
gui, show
return

WM_MouseMove()
{
   Tooltip := %A_GuiControl%_TT
   Tooltip, %tooltip%
   SetTimer, KillToolTip, 500
   return
}

KillToolTip:
   Tooltip   ;remove
return

GuiClose:
ExitApp

_________________
Image
"Power can be given overnight, but responsibility must be taught. Long years go into its making."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 4th, 2006, 2:46 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Although hover tooltips are on the informal to-do list, I don't know if/when it will be implemented. In the meantime, the great techniques here and in other topics should be useful. In fact, seeing a definitive implementation of ToolTips in a script may become the foundation of a built-in feature (because almost all the R&D and testing would already have been done).

Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 4th, 2006, 3:17 am 
Offline

Joined: February 13th, 2006, 10:40 pm
Posts: 389
Location: Utah
@Chris

Please clarify what you mean by "definitive implementation".

And by the way, do you know why text controls are not recognized by the WM_MOUSEMOVE function as the gui control that launched the function, thus making it impossible to give them a tooltip using my method?

_________________
Image
"Power can be given overnight, but responsibility must be taught. Long years go into its making."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 4th, 2006, 3:36 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Veovis wrote:
Please clarify what you mean by "definitive implementation".
An implementation that virtually anyone would agree is close to the best that can be achieved within the limits of the API (and preferably that doesn't use much CPU time).

Quote:
And by the way, do you know why text controls are not recognized by the WM_MOUSEMOVE function as the gui control that launched the function, thus making it impossible to give them a tooltip using my method?
I believe it's a limitation of the OS: it doesn't report the control when the mouse is hovering over a text control (perhaps under the belief that such controls are too unimportant to report). To work around this, perhaps you could use MouseGetPos (maybe you are already).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 2nd, 2006, 11:15 pm 
Offline

Joined: October 1st, 2005, 2:09 am
Posts: 130
Location: Canada
Thanks for the code, Veovis, it works good. The only overall problem with it is that tooltips don't actually disappear as long as the mouse stays over top of the control. But I am not looking for perfection in this case, and your code works great. :)

I opted for yours instead of the IfWinActive method as it wouldn't have fit in as nicely.

Edit: I've modified the code to fix the above problem. I did this by creating a global 'PREVIOUS_TOOLTIP' variable, which stores the last A_GuiControl, and if the current A_GuiControl is the same as PREVIOUS_TOOLTIP, the tooltip will not be shown, thus the Remove ToolTip works properly until the mouse is moved to a new control.

Code:
WM_MOUSEMOVE()
{
  global GUI_PREVTIP,GUI_ENABLETOOLTIPS
  GUI_CURTIP := A_GuiControl
  If (GUI_ENABLETOOLTIPS >= 1 and GUI_PREVTIP != GUI_CURTIP)
  {
    ; ToolTips
    _TT := ""
    First_TT := "This is a tooltip for the var 'First'"
    Second_TT := "This is a tooltip for the var 'Second'"

    myToolTip := %GUI_CURTIP%_TT
    ToolTip, %myToolTip%
    SetTimer, RemoveToolTip, 1600
    GUI_PREVTIP := GUI_CURTIP
    Return
  }
}

RemoveToolTip:
  ToolTip
Return


GUI_ENABLETOOLTIPS controls whether the user has tooltips enabled or not. GUI_PREVTIP is also a global var which stores the last A_GuiControl that the mouse was under. GUI_CURTIP is a local var which stores the current A_GuiControl.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 5th, 2006, 1:27 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Nice example. I've posted a slightly revised version on the GUI page:

Catching other events: Other types of GUI events can be detected and acted upon via OnMessage(). For example, a script can display context-sensitive help via ToolTip whenever the user moves the mouse over particular controls in the window.

Code:
Gui, Add, Edit, vMyEdit
MyEdit_TT := "This is a tooltip for the control whose variable is MyEdit."
Gui, Add, DropDownList, vMyDDL, Red|Green|Blue
MyDDL_TT := "Choose a color from the drop-down list."
Gui, Show
OnMessage(0x200, "WM_MOUSEMOVE")
return

WM_MOUSEMOVE()
{
   static PrevControl, _TT  ; _TT is defined as a static variable (blank) for use by the ToolTip command below.
   CurrControl := A_GuiControl
   If (CurrControl <> PrevControl)
   {
      ToolTip % %CurrControl%_TT
      SetTimer, RemoveToolTip, 4000
      PrevControl := CurrControl
   }
}

RemoveToolTip:
ToolTip
return

GuiClose:
ExitApp

Thanks to everyone who contributed to it. Corrections and improvements are welcome.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 5th, 2006, 11:50 pm 
Offline

Joined: October 1st, 2005, 2:09 am
Posts: 130
Location: Canada
Yeah, I knew I was on to a Good Thing (tm) when I revised the code. I didn't like how the tooltips stuck around while the mouse was over it. static variables, eh! I'll have to use those a lot more often. Thanks for the revised code Chris.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 7th, 2006, 1:31 pm 
Hello all

Let me start by saying "what a great thread". :)
I wouldn't have known where to start with a script like this.

I used Chris's version in one of my scripts and it works perfectly, except that when I click on a button that opens another gui and minimises the main gui, the main gui is not minimised if the tooltip is showing. Once the tooltip has gone the button works as it should.

Anyway, the reason for this post is that I decided that the tooltips where a bit annoying/distracting and got in the way, so as an alternative method of displaying info about controls I modified the code to use the status bar instead. I appreciate that this thread is about tooltips but it seems appropriate to post here.

Code:
Gui Margin, 2, 2
Gui Add, Edit, w220 vMyEdit
MyEdit_SB := "This control uses the variable MyEdit."
Gui Add, DropDownList, w220 vMyDDL, Red|Green|Blue
MyDDL_SB := "Choose a colour from the drop-down list."
Gui Add, StatusBar,,
Gui Show,,Control info in status bar.
OnMessage(0x200, "WM_MOUSEMOVE")
Return

WM_MOUSEMOVE()
{
   If ! A_GuiControl
      SB_SetText( "" )
   CurrControl := A_GuiControl
   If (CurrControl <> PrevControl)
   {
      SB_SetText( %CurrControl%_SB )
      PrevControl := CurrControl
   }
}

GuiClose:
ExitApp

Chris, is there any way to remove (or hide/disguise) the separator on the right hand side of the status bar when the bar isn't split into sections?

Kind regards


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 7th, 2006, 10:20 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
You could try SB_SetText's Style parameter. If that isn't sufficient, you might have to send the SB_* messages directly (assuming the API contains a way to achieve the desired effect).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2006, 1:13 am 
Thanks Chris.
Code:
Gui Margin, 2, 2
Gui Add, Edit, w220 vMyEdit
MyEdit_SB := "This control uses the variable MyEdit."
Gui Add, DropDownList, w220 vMyDDL, Red|Green|Blue
MyDDL_SB := "Choose a colour from the drop-down list."
Gui Add, StatusBar,,
Gui Show,,Control info in status bar.
OnMessage(0x200, "WM_MOUSEMOVE")
Return

WM_MOUSEMOVE()
{
   If ! A_GuiControl
      SB_SetText( "", 1, 1 )
   CurrControl := A_GuiControl
   If (CurrControl <> PrevControl)
   {
      SB_SetText( %CurrControl%_SB, 1, 1 )
      PrevControl := CurrControl
   }
}

GuiClose:
ExitApp


Kind regards


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2006, 4:23 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
I apologize for extending this thread but I just wanted to add a couple of penny's worth (or less)...

BooBoo wrote:
... I decided that the tooltips where a bit annoying/distracting and got in the way...

I think that BooBoo's (and my) largest aversion to the cursor-controlled tooltip solution is that tooltips of this nature usually require that the cursor hover over the field a little while (~1 second) before the tooltip is displayed. I made a minor modification to Chris' version and came up with this:

Code:
Gui, Add, Edit, vMyEdit
MyEdit_TT := "This is a tooltip for the control whose variable is MyEdit."
Gui ,Add, DropDownList, vMyDDL, Red|Green|Blue
MyDDL_TT := "Choose a color from the drop-down list."
Gui, Add, Edit, vMyEdit2,This don't got no tip
Gui, Show
OnMessage(0x200,"WM_MOUSEMOVE")
return

WM_MOUSEMOVE()
    {
    global
    CurrControl:=A_GuiControl
    if (CurrControl<>PrevControl)
        {
        SetTimer DisplayToolTip,1000
        PrevControl:=CurrControl
        }
    }

DisplayToolTip:
SetTimer DisplayToolTip,off
ToolTip % %CurrControl%_TT
SetTimer,RemoveToolTip,4000
return

RemoveToolTip:
SetTimer RemoveToolTip,off
ToolTip
return

GuiClose:
ExitApp



BooBoo wrote:
... so as an alternative method of displaying info about controls I modified the code to use the status bar instead.

I like the idea of using the status bar to display object help (hints), but IMHO, the status bar is more appropriate for displaying hints for objects that are in focus. I made some minor modifications to BooBoo's code and came up with this:
Code:
Gui Margin, 2, 2
Gui Add, Edit, w220 vMyEdit
MyEdit_SB := "This control uses the variable MyEdit."
Gui Add, DropDownList, w220 vMyDDL, Red|Green|Blue
MyDDL_SB := "Choose a colour from the drop-down list."
Gui Add, Edit, w220 vMyDDL2,I ain't got no hint
Gui Add, StatusBar,,
Gui Show,,Control info in status bar.
OnMessage(0x101,"UpdateHint")  ;-- WM_KEYUP
OnMessage(0x202,"UpdateHint")  ;-- WM_LBUTTONUP
UpdateHint()
Return

UpdateHint()
    {
    static PrevControl,_SB
    GUIControlGet CurrControl,FocusV
    If (CurrControl<>PrevControl)
        {
        SB_SetText(%CurrControl%_SB)
        PrevControl:=CurrControl
        }
    }

GuiClose:
ExitApp

There may be more appropriate windows messages to use than the ones I've selected.

Depending on the type of objects you put in your GUI, it may be more efficient to replace the OnMessage statements with a timer. Of course, the UpdateHint function must be converted into a subroutine if this were done.


Final thoughts...
Since some objects rarely come into focus (some radio buttons for example), it might be a good idea to use both tooltips (cursor) and the status bar (focus) to display object help. Them be my thoughts...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 17th, 2006, 10:16 pm 
Offline

Joined: July 15th, 2006, 7:36 pm
Posts: 31
It seems very un-elegant to "require" a variable on all the buttons whether they have a tip or not.

I'll take a peek tonight and see what we can do about that.. Though, an answer is not apparent to me at the moment.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 5 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group