| View previous topic :: View next topic |
| Author |
Message |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 411 Location: Galil, Israel
|
Posted: Tue Jan 01, 2008 3:18 pm Post subject: A_ThisMenuItem is really a_LastMenuItem |
|
|
and, not sure if qualifies as 'bug', but....
A_ThisMenuItem returns LAST SELECTED MENU ITEM
even if THIS (most recent) selection was Null (ie. escape from menu).
would be nice to be able to know that NO item was selected, instead of being misled with value from LAST MENU in which ther WAS a selection. _________________ Joyce Jamce |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6349 Location: Pacific Northwest, US
|
Posted: Wed Jan 02, 2008 6:16 am Post subject: |
|
|
not technically a bug - moving to wish list.
I have not read ahk for help yet tonight. Did my suggestion work? I guess I'll find out. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2474 Location: Australia, Qld
|
Posted: Wed Jan 02, 2008 7:02 am Post subject: Re: A_ThisMenuItem is really a_LastMenuItem |
|
|
| Joy2DWorld wrote: | | A_ThisMenuItem returns LAST SELECTED MENU ITEM |
That's right.
| Quote: | | The name of the most recently selected custom menu item (blank if none). |
| Joy2DWorld wrote: | | even if THIS (most recent) selection was Null (ie. escape from menu). | Technically, if you escaped from the menu, no selection happened, therefore the "most recently selected custom menu item" is the same as before.
I agree that cancelling should update A_ThisMenuItem, but why don't you just use the menu item labels? If no label executes, the user cancelled... (I suspect A_ThisMenuItem doesn't update because AutoHotkey doesn't receive a notification from the menu.)
I've never had a need for A_ThisMenuItem outside of menu item labels... |
|
| Back to top |
|
 |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 411 Location: Galil, Israel
|
Posted: Wed Jan 02, 2008 1:31 pm Post subject: |
|
|
have started find a lot of nice uses for majkinetor's showmenu() function [with some small mods, see my post at] http://www.autohotkey.com/forum/viewtopic.php?t=23138&start=0
and now use the menu as a selection, not direction tool. For ex. I time how long the menu displays before a selection made, and if longer than short, turn on extra confirmation messages, etc.
(eg. delete option if user took a LONG time to select it, pops up confirmation, but if selected quickly, does not).
using gosub %selected% to do the actuall sub call.
(and, now also.. [@lexikos, thanks to your genius breakthru!], eval_(selected) to process function calls effortlessly via menu path selection).
anyhow... manually tracking selection or not works as a work-around... but ...
seems more simple and sound to access the global var and get a 'true' answer as to user's last menu action.... _________________ Joyce Jamce |
|
| Back to top |
|
 |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 411 Location: Galil, Israel
|
Posted: Wed Jan 02, 2008 1:34 pm Post subject: |
|
|
@engunneer,
actually,
doc says
| Quote: | | The name of the most recently selected custom menu item (blank if none). |
but if NONE was selected the A_THISMENUITEM is not blank.
bug ? _________________ Joyce Jamce |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2474 Location: Australia, Qld
|
Posted: Wed Jan 02, 2008 1:59 pm Post subject: |
|
|
That sounds like it should be directed at me rather than engunneer...
If a menu item was selected last time a menu was shown, it is the most recently selected menu item. "None" refers to the menu item ("no such menu item"), not the selection ("nothing was selected").
| Quote: | | seems more simple and sound to access the global var and get a 'true' answer as to user's last menu action.... | A_ThisMenuItem does access the global var. After further research, it seems I was correct when I said:
| Quote: | | (I suspect A_ThisMenuItem doesn't update because AutoHotkey doesn't receive a notification from the menu.) |
A_ThisMenuItem is only updated when a menu item is selected. When the menu is cancelled, no selection takes place. There is a difference between selecting "nothing"
and not selecting anything.
Perhaps A_ThisMenuItem (aka g_script.mThisMenuItemName) should be emptied directly before showing the menu. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6349 Location: Pacific Northwest, US
|
Posted: Wed Jan 02, 2008 7:19 pm Post subject: |
|
|
| lexikos wrote: |
Perhaps A_ThisMenuItem (aka g_script.mThisMenuItemName) should be emptied directly before showing the menu. |
Well put. This is, I think, a good wish to come out of this. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Mustang
Joined: 17 May 2007 Posts: 368 Location: England
|
Posted: Wed Jan 02, 2008 8:54 pm Post subject: |
|
|
| Joy2DWorld wrote: | | Quote: | | The name of the most recently selected custom menu item (blank if none). |
but if NONE was selected the A_THISMENUITEM is not blank. |
By "blank if none" it means no menu selection has occured since the script started
Not selection was cancelled between opening a menu and not selecting an item from the list
Hope that helps clear it up
But I agree it would be a nice addition
Just whether or not it would break any current scripts remains to be seen |
|
| Back to top |
|
 |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 411 Location: Galil, Israel
|
Posted: Thu Jan 03, 2008 1:22 am Post subject: |
|
|
| Mustang wrote: | | Joy2DWorld wrote: | | Quote: | | The name of the most recently selected custom menu item (blank if none). |
but if NONE was selected the A_THISMENUITEM is not blank. |
By "blank if none" it means no menu selection has occured since the script started
Not selection was cancelled between opening a menu and not selecting an item from the list
|
don't buy into that interp of that language. Obviously if program never calls a menu the var should be blank...
"blank if none" since is added to instruction has to mean something. Does it refer to "selected" menu item, or "menu item" generally ? Since var relates to selected item, "The name of ...", so does blank.
so, if NONE of the menu items was selected, (ie. escape from menu), the var should be blank... _________________ Joyce Jamce |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6349 Location: Pacific Northwest, US
|
Posted: Thu Jan 03, 2008 1:54 am Post subject: |
|
|
AHK isn't told that the menu was escaped from. The only way to behave this way is to blank it whenever a menu is shown, which was mentioned above. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2474 Location: Australia, Qld
|
Posted: Thu Jan 03, 2008 3:34 am Post subject: |
|
|
| Joy2DWorld wrote: | | "blank if none" since is added to instruction has to mean something. Does it refer to "selected" menu item, or "menu item" generally ? | Say you do this:
- show menu A
- click item A1
Item A1 is now the most recently selected custom menu item.
- show menu B
- click item B2
Item B2 is now the most recently selected custom menu item.
You didn't select any menu items, so item B2 is still the most recently selected custom menu item.
What if no menu item has been selected, or no menus have been shown?
"The most recently selected custom menu item" is not applicable. Since no such menu item exists, A_ThisMenuItem is blank.
i.e. "none" refers to "the most recently selected custom menu item".
| Joy2DWorld wrote: | don't buy into that interp of that language.
| I'm not saying how it currently works is how it should be, only that the documentation is accurate (though perhaps a bit vague.) |
|
| Back to top |
|
 |
|