AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Onclick clear edit box

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
ecksphore



Joined: 21 Nov 2006
Posts: 191

PostPosted: Thu Jul 16, 2009 2:50 am    Post subject: Onclick clear edit box Reply with quote

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
View user's profile Send private message
Fry



Joined: 01 Nov 2007
Posts: 885

PostPosted: Thu Jul 16, 2009 3:36 am    Post subject: Reply with quote

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
View user's profile Send private message
guestx
Guest





PostPosted: Thu Jul 16, 2009 5:06 am    Post subject: Reply with quote

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





PostPosted: Thu Jul 16, 2009 5:11 am    Post subject: Reply with quote

Forgot to delete an unneeded line. Embarassed
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

PostPosted: Thu Jul 16, 2009 5:09 pm    Post subject: Reply with quote

Thank you! Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group