| View previous topic :: View next topic |
| Author |
Message |
ILL.1
Joined: 29 Sep 2004 Posts: 84
|
Posted: Wed Sep 29, 2004 3:44 pm Post subject: GUI Picture and Add Button |
|
|
I found a problem with sending mouse clicks in a GUI.
I created a simple gui with the following:
| Code: | MyPic = PATH TO PICTURE
GUI, Add, Picture, xm ym, %MyPic%
GUI, Add, Button, gOK xm ym, OK
GUI, Add, Button, gCancel xm ym+20, Cancel
GUI, Show, , Background Test
Return
Cancel:
GuiClose:
ExitApp
OK:
GUI, submit
MsgBox, OK Clicked
ExitApp |
When the buttons are over top of the picture, mouse clicks do not work. Keyboard input does work. Is there something that I am missing, or is this how the GUI is suppose to work? _________________ ===============
----------ILL.1-----------
=============== |
|
| Back to top |
|
 |
Nemroth
Joined: 07 Sep 2004 Posts: 262 Location: France
|
Posted: Wed Sep 29, 2004 5:58 pm Post subject: |
|
|
The AHK Help file says :
| Quote: | Options for Assigning Actions and Variables
G: Gosub. To launch a subroutine in response to the press of a button, changing of a checkbox/radio, selection of a new choice, or the clicking of a picture or text control: include the letter G followed immediately by the name of the label to execute.... |
So try :
| Code: | MyPic = PATH TO PICTURE
GUI, Add, Picture, xm ym gPicProc, %MyPic%
GUI, Add, Button, gOK xm ym, OK
GUI, Add, Button, gCancel xm ym+20, Cancel
GUI, Show, , Background Test
Return
Cancel:
GuiClose:
ExitApp
OK:
GUI, submit
MsgBox, OK Clicked
ExitApp
PicProc:
;here your procedure
return |
May be I'm wrong... |
|
| Back to top |
|
 |
ILL.1
Joined: 29 Sep 2004 Posts: 84
|
Posted: Wed Sep 29, 2004 6:22 pm Post subject: |
|
|
My understanding of that command leads me to believe that if I wanted an action to occur if I pressed the picture it would assign a label like you did. So, after adding the code like you suggested I did a little trouble shooting. It seems that the picture is considered to be in front, even though the buttons are on top. Do you know of a way to keep the buttons in front of the picture? Or is there a way to make the button clicks pass throguh the picture but not the GUI? _________________ ===============
----------ILL.1-----------
=============== |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1717
|
Posted: Wed Sep 29, 2004 7:33 pm Post subject: |
|
|
ur script works fine for me... make sure u've the latest download. _________________
 |
|
| Back to top |
|
 |
Nemroth
Joined: 07 Sep 2004 Posts: 262 Location: France
|
Posted: Wed Sep 29, 2004 7:36 pm Post subject: |
|
|
Well I must say I don't know why, when you click on one of the buttons, this is the action of the click on the picture wich is fired.
May be as the buttons are in the aera of the picture they are considered as part of the picture ???
Is it a bug or a normal behaviour ?
Please Chris, help !!!
But perhaps is it a good idea to implement, if it's possible, the equivalent of the HTML image maps in the AHK's GUI ?
Please Chris, do you think you can do that ? |
|
| Back to top |
|
 |
Nemroth
Joined: 07 Sep 2004 Posts: 262 Location: France
|
Posted: Wed Sep 29, 2004 7:38 pm Post subject: |
|
|
to Rajat :
I have Win 98SE and the last version of AHK and the script works for me like I said. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Wed Sep 29, 2004 7:44 pm Post subject: |
|
|
Rajat's right: The issue with pictures "stealing clicks" was recently fixed. It sounds like your version is slightly too old to have that fix.
To take advantage of the fix, your picture mustn't have an associated g-label in its options.
Although already present in the installer, this fix will be announced in the changelog for version 1.0.20, which is due out tomorrow hopefully. |
|
| Back to top |
|
 |
Nemroth
Joined: 07 Sep 2004 Posts: 262 Location: France
|
Posted: Wed Sep 29, 2004 7:49 pm Post subject: |
|
|
| Nemroth wrote: | But perhaps is it a good idea to implement, if it's possible, the equivalent of the HTML image maps in the AHK's GUI ?
Please Chris, do you think you can do that ? |
What do you think about that, Chris ?
Do you think it's a good idea ? Is it possible to do ? |
|
| Back to top |
|
 |
Nemroth
Joined: 07 Sep 2004 Posts: 262 Location: France
|
Posted: Wed Sep 29, 2004 7:54 pm Post subject: |
|
|
About the subject of this post :
I have the last version of AHK, with the last modifications.
I tried with and without the "G" parameter
With : the 2 buttons and the pict give the G Pict procedure as result.
Without : nothing happens for me clicing on the pict or the buttons.
I have Win 98SE |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Wed Sep 29, 2004 7:54 pm Post subject: |
|
|
I'll make a note of it, but you may already know you could do it using something like the following: | Code: | Gui, Add, Pic, gMyPicClick, MyPic.jpg
...
return
MyPicClick:
MouseGetPos, ClickX, ClickY
ControlGetPos, PicX, PicY, PicW, PicH, Static4, A
... now compare the above coordinates and dimensions to figure out where in the picture the user clicked ...
return |
Last edited by Chris on Wed Sep 29, 2004 7:58 pm; edited 1 time in total |
|
| Back to top |
|
 |
ILL.1
Joined: 29 Sep 2004 Posts: 84
|
Posted: Wed Sep 29, 2004 7:55 pm Post subject: |
|
|
I'll download the new version once I get the chance. _________________ ===============
----------ILL.1-----------
=============== |
|
| Back to top |
|
 |
Nemroth
Joined: 07 Sep 2004 Posts: 262 Location: France
|
Posted: Wed Sep 29, 2004 8:02 pm Post subject: |
|
|
Thanks Chris for your interesting code.
For me the equivalent of the HTML image maps is just a suggestion as I have personally no use of sutch a feature. But perhaps it ca be usefull for some guys. |
|
| Back to top |
|
 |
ILL.1
Joined: 29 Sep 2004 Posts: 84
|
Posted: Thu Sep 30, 2004 12:52 pm Post subject: |
|
|
Downloaded the latest version and all is fixed. I was going to use the MouseGetPos, but I wanted to see if there was a fix for this first. I did a bit of a search before I posted and didn't see any answers to a fix. From now on I'll make sure that I have the lastest download. Thanks for all your help. _________________ ===============
----------ILL.1-----------
=============== |
|
| Back to top |
|
 |
Guest
|
Posted: Fri Oct 01, 2004 10:27 am Post subject: |
|
|
Appologies. I tried once again with 1.0.20 version and it's OK under W98 SE
For me too it was a version problem and I was sure th had install the last 1.0.19 one... |
|
| Back to top |
|
 |
|