| View previous topic :: View next topic |
| Author |
Message |
vahju
Joined: 17 Feb 2008 Posts: 296
|
Posted: Tue Oct 21, 2008 7:47 pm Post subject: Any way to clear edit control upon focus or initial change |
|
|
So I have this edit control that contains some default text.
| Code: | | Gui, Add, Edit, r3 vEditText y+10 w140, Add some extra notes. |
What I would like to do is when someone clicks in the edit control the default text is cleared. I could not find a built in option in the help system.
This GUI I am creating will eventually take the input from all controls and put them in the clipboard to be pasted in helpdesk tickets. I don't want the "add some extra notes" in every ticket.
Any ideas? |
|
| Back to top |
|
 |
Serenity
Joined: 07 Nov 2004 Posts: 1271
|
Posted: Tue Oct 21, 2008 7:56 pm Post subject: |
|
|
You can use OnMessage to catch clicks in the Edit control:
| Code: | Gui, Add, Edit, r3 vEditText HwndEdit y+10 w140, Add some extra notes.
Gui, Show
OnMessage(0x201, "WM_LBUTTONDOWN")
Return
WM_LBUTTONDOWN(wParam, lParam, Msg, hWnd)
{
Global Edit
If (hWnd = Edit)
GuiControl,, Edit1
} |
_________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
|
| Back to top |
|
 |
vahju
Joined: 17 Feb 2008 Posts: 296
|
Posted: Wed Oct 22, 2008 5:00 pm Post subject: |
|
|
Serenity I tried you suggestion and it clears the edit field but for some reason no matter what contol I click on it minimizes or hides the GUI.
I really don't understand the WM_LButtonDown parameters. This is the first time I have every used this type of code. From what I can see the hWnd is passed and it compares it to Edit. But for some reason it is making the comparison no matter what GUI control I click on.
| Code: | WM_LBUTTONDOWN(wParam, lParam, Msg, hWnd)
{
Global Edit
Edit
If (hWnd = Edit)
{
GuiControl,,Edit1
}
} |
|
|
| Back to top |
|
 |
vahju
Joined: 17 Feb 2008 Posts: 296
|
Posted: Thu Oct 23, 2008 4:09 pm Post subject: |
|
|
| SKAN thanks for the link. The Timer approach worked perfectly. |
|
| Back to top |
|
 |
|