 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Sat Jan 03, 2009 8:03 am Post subject: Need help with detecting single mouse click in Edit control |
|
|
For some reason the Text box is getting the focus, not the edit control. How do I have the edit control get focus?
Update:
Umm... hmm.. It works if I disable Test1. Is there a way that doesn't disable Test1?
| Code: | #SingleInstance Force
#NoEnv
Gui, Font, s18
Gui, Add, Text, gTest1 vTest1 w30 h30 x10 y10, S
Gui, Add, Edit, gTest2 vTest2 Limit1 w30 h30 x10 y10 -Multi, S
Gui, Show
return
Test1:
{
if (A_GuiEvent = "DoubleClick")
MsgBox, test1
return
}
Test2:
{
if (A_GuiEvent = "DoubleClick")
MsgBox, test2
return
}
GuiClose:
ExitApp |
Much thanks. _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts.
Last edited by animeaime on Sat Jan 03, 2009 9:47 am; edited 1 time in total |
|
| Back to top |
|
 |
Neight
Joined: 31 Dec 2008 Posts: 23
|
Posted: Sat Jan 03, 2009 9:43 am Post subject: |
|
|
| Code: | Gui, Font, s18
Gui, Add, Text, gTest1 vTest1 w30 h30 x10 y10, S
Gui, Add, Edit, gTest2 vTest2 Limit1 w30 h30 x10 y10 -Multi, S
Gui, Show
return
Test1:
If A_EventInfo = DoubleClick
MsgBox, test1
Return
/* Edit controls only have one label activation (Keystrokes) :(
Test2:
{
if (A_GuiEvent = "DoubleClick")
MsgBox, test2
return
}
*/
GuiClose:
ExitApp |
_________________ Ask stupid questions, get stupid answers.
Search before posting! |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Sat Jan 03, 2009 9:47 am Post subject: |
|
|
Oh... bummer. I there a way for it to detect a single click then? I'm trying to have it select the contents on double click. Right now I have to disable the Text box and its causing problems. So, I'll settle for second prize - do you know how to get it select the contents when I double click on the edit box? _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
Neight
Joined: 31 Dec 2008 Posts: 23
|
Posted: Sat Jan 03, 2009 4:36 pm Post subject: |
|
|
| Code: | Gui, Font, s18
Gui, Add, Text, gTest1 vTest1 w30 h30 x10 y10, S
Gui, Add, Edit, vTest2 Limit1 w30 h30 x10 y10 -Multi, S
OnMessage(0x201, "WM_LButtonDown")
Gui, Show
return
Test1:
If A_EventInfo = DoubleClick
MsgBox, test1
Return
GuiClose:
ExitApp
WM_LButtonDown() {
MouseGetPos, X, Y, Win, Ctrl
If (Ctrl == "Edit1")
MsgBox, test2
} |
_________________ Ask stupid questions, get stupid answers.
Search before posting! |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Sat Jan 03, 2009 7:48 pm Post subject: |
|
|
That doesn't do quite what I need. I guess my wording was off. I want all mouse clicks to be caught by the Edit box (right now, they are caught by the Text box) - I need to be able to edit the text, so I need to click on the edit box and edit the text, but it won't register the mouse. It works fine if you disable or hide the text box, but that is causing some side effects of its own. _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Sun Jan 04, 2009 4:25 pm Post subject: |
|
|
Have you considered a workaround like this?
| Code: | #SingleInstance Force
#NoEnv
Gui, Font, s18
Gui, Add, Text, gTest1 vTest1 w30 h30 x10 y10, S
Gui, Add, Edit, Limit1 vTest2 w30 h30 x10 y10 -Multi, S
Gui, Show
return
GuiClose:
ExitApp
Test1:
if (A_GuiEvent = "Normal")
ControlClick, Edit1, ahk_class AutoHotkeyGUI
Else if (A_GuiEvent = "DoubleClick")
ControlSend, Edit1, ^a, ahk_class AutoHotkeyGUI
return |
...and out of curiosity, may I ask what the overlapping controls are for? |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Sun Jan 04, 2009 8:08 pm Post subject: |
|
|
Thanks. I found a way that works. I hide the text box, then show it like how I first posted, but I use a variable to detect whether the edit control is active or not.
The reason I asked is because of this post. They wanted to make a crossword gui, and my solution includes having text controls show the cells, and upon clicking on a cell, an edit box is shown to allow user input. It's actually nice code if you ever find yourself wanting a crossword-like gui - check it out.. _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| 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
|