 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
ecksphore
Joined: 21 Nov 2006 Posts: 191
|
Posted: Thu Jul 16, 2009 2:50 am Post subject: Onclick clear edit box |
|
|
Is it possible to clear a edit box when a user click their mouse in it?
If so, could someone give me an example? Thanks! |
|
| Back to top |
|
 |
Fry
Joined: 01 Nov 2007 Posts: 885
|
Posted: Thu Jul 16, 2009 3:36 am Post subject: |
|
|
Not without doing some work.
Heres how:
Use GuiControlGet to get position of control
Use MouseGetPos to check if the mouse is in the area of the edit box
If it is, clear the edit box |
|
| Back to top |
|
 |
guestx Guest
|
Posted: Thu Jul 16, 2009 5:06 am Post subject: |
|
|
It is simple (this code adapted from help file example of OnMessage).
| Code: | #SingleInstance, force
Gui, Add, Text,, Click anywhere in this window.
Gui, Add, Edit, r4 w200 vMyEdit, line 1`nline 2`nline 3
Gui, Show
OnMessage(0x201, "WM_LBUTTONDOWN")
return
WM_LBUTTONDOWN(wParam, lParam)
{
if (A_GuiControl = "MyEdit") {
GuiControl,, MyEdit,
Control := "`n(in control " . A_GuiControl . ")"
}
}
GuiClose:
ExitApp |
|
|
| Back to top |
|
 |
guestx Guest
|
Posted: Thu Jul 16, 2009 5:11 am Post subject: |
|
|
Forgot to delete an unneeded line.
| Code: | #SingleInstance, force
Gui, Add, Text,, Click anywhere in this window.
Gui, Add, Edit, r4 w200 vMyEdit, line 1`nline 2`nline 3
Gui, Show
OnMessage(0x201, "WM_LBUTTONDOWN")
return
WM_LBUTTONDOWN(wParam, lParam)
{
if (A_GuiControl = "MyEdit") {
GuiControl,, MyEdit,
}
}
GuiClose:
ExitApp |
|
|
| Back to top |
|
 |
ecksphore
Joined: 21 Nov 2006 Posts: 191
|
Posted: Thu Jul 16, 2009 5:09 pm Post subject: |
|
|
Thank you!  |
|
| 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
|