AutoHotkey Community

It is currently May 26th, 2012, 6:35 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Easier use of menus
PostPosted: June 24th, 2005, 12:18 pm 
Offline

Joined: June 11th, 2005, 10:56 pm
Posts: 6
I've come up with a couple of points that could make it a little easier to code pop-up menus. Nothing critical, so no bother if nothing happens.

1) Possibly confusing behaviour if the user presses escape to cancel.

If the user presses escape on a menu, that makes the menu disappear, and the "Menu, Show" command completes. So far, that's exactly what I expect.

a) It would be useful for the script to be able to tell that escape was pressed. For example, ErrorLevel could be set depending on whether the user selected an item or not.

I agree, I can already work this out for myself, but it's slightly messy: e.g during each menu handler routine I set a variable "ItemSelected", so I know that if the variable isn't set, then escape was pressed.

b) When escape is pressed, the A_ThisMenuItem and A_ThisMenuItemPos variables are still set to the values left over from the previous menu item that was selected by the user. It could be safer it they were set to 'null' values such as 0 and "".

I can see that I only hit this because I wrote my program the wrong way. But it would have been much easier to figure out what I'd done wrong if the behaviour had been consistent rather than floating.

2) Make it easier to ensure a menu is empty.

Currently, Menu, Delete fails if the menu doesn't exist, but I reckon it would be better if instead it just worked OK. The coder is requesting for the menu to be deleted, and it already is, so it's hard to see how allowing the script to continue is going to cause a problem.

The reason I want this is because I need to write code to delete a menu, and it needs to work whether the menu exists or not. So now I have to write the following:

Menu, Temp, Add
Menu, Temp, Delete

It would be easier if I could just write the second line.

Many thanks for any help or advice


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Easier use of menus
PostPosted: June 25th, 2005, 2:35 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
ApplePie wrote:
It would be useful for the script to be able to tell that escape was pressed. For example, ErrorLevel could be set depending on whether the user selected an item or not.
I agree that it would be good, but from what I can tell, it would require a different menu mode of operation. This would require a redesign of certain complex parts of the program. Even so, it's something I'll try to keep in mind when the time comes to do more menu improvements, such as icons and multi-columns.

Quote:
b) When escape is pressed, the A_ThisMenuItem and A_ThisMenuItemPos variables are still set to the values left over from the previous menu item that was selected by the user. It could be safer it they were set to 'null' values such as 0 and "".
You're probably right, but I think it's best not to change it because of the likelihood of breaking existing scripts. In hindsight, certain aspects of the program like this one could have been done better.

Quote:
Currently, Menu, Delete fails if the menu doesn't exist, but I reckon it would be better if instead it just worked OK.
Try using Menu, Tray, UseErrorLevel -- it prevents menu error dialogs and instead sets ErrorLevel. This setting affects all menus, not just the Tray menu.

Thanks for your suggestions.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 15th, 2005, 1:20 pm 
Offline

Joined: June 11th, 2005, 10:56 pm
Posts: 6
Thanks Chris, your reply makes sense.

Cheers
A


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group