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 

Menu wrapper library
Goto page Previous  1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
animeaime



Joined: 04 Nov 2008
Posts: 1046

PostPosted: Thu Feb 05, 2009 3:50 am    Post subject: Reply with quote

True, true, Yeah, it's very hard, for me, to think of how to present my libraries because I try to keep everything generic - which causes confusion, at times, especially when I start talking about "project-specific" values. Between my class library which has been out a few days and this, I'm sure eventually someone is going to ask me "what the #$!& does 'project-specific' mean??!" - or something like that.

You should continue your projects if you enjoy them. I know for me, what frustrates me the most is when I start working on a project, realize that I need something to have the project meet my vision and then get side-tracked by the "new project" that will help me with the "old project". I mean, I wrote the class library and this menu wrapper to help me with the bookmarks manager I'm planning to sell. However, I can't leave these half baked, so I'm going to update some "tutorials" for the class library and will probably end up doing the same for this library. Truthfully, I wish I had the personality to just present the information how I have, and go back to my project... Actually, I think I will. I've been avoiding updating the website for the class library because that's not my passion - I love to code, not write up websites full of documentation (god bless Chris for all the docs he wrote up), but until the demmand increases, I think explanations will be best... maybe *sigh*
_________________
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
View user's profile Send private message Send e-mail
Drugwash



Joined: 07 Sep 2008
Posts: 608
Location: Ploiesti, RO

PostPosted: Thu Feb 05, 2009 4:06 am    Post subject: Reply with quote

Oh well, anything is better than nothing so at least the code snippets and discussions posted around should be of help.

As for getting side-tracked... so true! I just seem to ask for the most impossible features from AHK and as such (almost) nobody can lend a hand, especially when I mention Win9x - as if it were a rabid dog, jeez! Then I have to take it from scratch with some helper script and it grows and it takes so much time that the original project falls into oblivion.

Ugh, I'm getting mushy at 6AM. I'd better hit the sack. Have a good one! Wink
Back to top
View user's profile Send private message Yahoo Messenger
animeaime



Joined: 04 Nov 2008
Posts: 1046

PostPosted: Thu Feb 05, 2009 1:32 pm    Post subject: Reply with quote

If you ever need a helping hand, I love a good challenge so feel free to PM with the situation. Of course, you can see my posts all across this forum asking how to do very specific things - it's just our nature as programmers Wink
_________________
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
View user's profile Send private message Send e-mail
animeaime



Joined: 04 Nov 2008
Posts: 1046

PostPosted: Thu Feb 05, 2009 2:19 pm    Post subject: Reply with quote

It hit me when I woke up that because the changes I made, Menu_DeleteAll didn't function how it should. I added a fix so that if a menu has standard items, those items are not deleted when using Menu_DeleteAll - to mimic the behavior of AHK. Also, the MenuItem object, Menu object, icons, menu handle, and other data (checkmarks, disabled, etc.) for the standard menu items is not affected when using DeleteAll.

Also, there was a bug that Menu_Standard couldn't be called on a menu that hasn't been created. This bug is now fixed.

In addition, I realized that the "template" was no longer a template at all, and was instead a "setup". So, I renamed it MenuLibrarySetup.ahk. Include the file in your library as before. Also, instead of calling MenuLibraryTemplate() in your code, call MenuLibrarySetup() and it will setup the menu library for use. There is now a MenuLibraryTemplate.ahk file that is the template design. It includes the necessary functions to cleanup the objects created and the Menu_fixUpMenuLabel function - both the AHK default and the one used in the test to remove spaces from the MenuItemName and it it for the label-or-submenu (when label-or-submenu is blank).

You can download the latest updates from here.
_________________
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
View user's profile Send private message Send e-mail
Drugwash



Joined: 07 Sep 2008
Posts: 608
Location: Ploiesti, RO

PostPosted: Thu Feb 05, 2009 2:56 pm    Post subject: Reply with quote

Good morning! Don't tell me you're dreaming of AHK... Very Happy

I updated the files. There's one thing I haven't got to test until now and I'm afraid it's not working (is it supposed to? dunno): (un)checkmarking menus.

I have Menu2 > Item2 that is checked by default. Clicking it will not unmark it. Also none of the items in Menu1 will get marked when clicked. Neither would the Make This Selection item.

One other thing - most likely related - is that there's an empty space to the left of all menu icons, probably for the checkmarks. But when there's no markable item and/or the markable items don't have an icon whiel others do, it may be more elegant (if possible) to use icon's place for the checkmarks and avoid the empty column to the left of the menu.
Back to top
View user's profile Send private message Yahoo Messenger
animeaime



Joined: 04 Nov 2008
Posts: 1046

PostPosted: Thu Feb 05, 2009 3:41 pm    Post subject: Reply with quote

Drugwash wrote:
Don't tell me you're dreaming of AHK... Very Happy

Well, you know... maybe.

Drugwash wrote:
Clicking it will not unmark it

The menu items don't check themselves sillly - you can add that ability though. For example, make a label called ToggleCheck, then you can have the item, when clicked, call ToggleCheck.

This label ToggleCheck can be used for any item you wish to have this functionality.

Code:
#NoEnv ;Must be specified to work - tried to find out why, no luck
;either include the template here or your project-specific "make up" of the template
#Include MenuLibraryTemplate.ahk

Menu_Add("Tray", "Item1")
return

Item1:
{
    gosub ToggleCheck

    ;your code goes here
   
    return
}

ToggleCheck:
{
    Menu, %A_ThisMenu%, ToggleCheck, %A_ThisMenuItem%
    return
}


You can use the same idea for Check, UnCheck, Enable, Disable, ToggleEnable, and Default

Drugwash wrote:
there's an empty space to the left of all menu icons, probably for the checkmarks

Right, there is. Forgot to mention that. That's the default behavior. The call below, which is a call to Lexikos' Menu Icons function (included in MenuItem.ahk) can "fix" that.

Code:
MI_SetMenuStyle(MenuNameOrHandle, 0x4000000) ; MNS_CHECKORBMP


Update:
Because you have to do that for each menu, should I make that the default bevahior? Meaning, when the menu is created, it would set that value? What's your thoughts? I mean, the user could always undo it by calling MI_SetMenuStyle(MenuNameOrHandle, 0). Also, any icon they set is retained (same with if you uncheck the item, the icon is used instead).
_________________
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
View user's profile Send private message Send e-mail
Drugwash



Joined: 07 Sep 2008
Posts: 608
Location: Ploiesti, RO

PostPosted: Thu Feb 05, 2009 4:26 pm    Post subject: Reply with quote

Hmm, I only used the test script so far and thought every options were functional, including check/uncheck item, that's why I mentioned it above. Haven't yet gotten to actually using the provided functions in my scripts.

Guess it's best to hide the empty space as default and only change the style when needed.

My biorhythm doesn't look very well these days... Confused
Back to top
View user's profile Send private message Yahoo Messenger
animeaime



Joined: 04 Nov 2008
Posts: 1046

PostPosted: Thu Feb 05, 2009 4:34 pm    Post subject: Reply with quote

Drugwash wrote:
Hmm, I only used the test script so far and thought every options were functional, including check/uncheck item, that's why I mentioned it above.

Do you mean that it doesn't check the item? I'm not sure I understand the problem.

Drugwash wrote:
Guess it's best to hide the empty space as default and only change the style when needed.

Ok, I'll add that in with the next release then.

Drugwash wrote:
My biorhythm doesn't look very well these days... Confused

What do you meann, are you not feeling well?
_________________
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
View user's profile Send private message Send e-mail
Drugwash



Joined: 07 Sep 2008
Posts: 608
Location: Ploiesti, RO

PostPosted: Thu Feb 05, 2009 4:44 pm    Post subject: Reply with quote

Quote:
Do you mean that it doesn't check the item?
Exactly. Doesn't check, doesn't uncheck. Only displays the debug message boxes about which item was chosen and whatever other info is in there (haven't looked into the code).
Quote:
Ok, I'll add that in with the next release then.
Thank you, I hope it's the best choice. Would be best if other interested users would chime in with their own opinion.
Quote:
What do you mean, are you not feeling well?
Too complicated to discuss here. Generally no, I'm not exactly well. But don't worry, it's not because of your script. Smile
Back to top
View user's profile Send private message Yahoo Messenger
animeaime



Joined: 04 Nov 2008
Posts: 1046

PostPosted: Thu Feb 05, 2009 4:50 pm    Post subject: Reply with quote

Drugwash wrote:
Exactly. Doesn't check, doesn't uncheck

So you don't get a msgbox that says 8 (which means the item is checked)?

Drugwash wrote:
Too complicated to discuss here.

You can always PM me if you want to talk.

Also, about your PM, I think it's over my head. I'm going to look it at later, but from the look of it, it's beyond me.
_________________
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
View user's profile Send private message Send e-mail
Drugwash



Joined: 07 Sep 2008
Posts: 608
Location: Ploiesti, RO

PostPosted: Thu Feb 05, 2009 5:09 pm    Post subject: Reply with quote

Quote:
So you don't get a msgbox that says 8 (which means the item is checked)?
Here's what I get when clicking Menu1 > Item3:
-------- messagebox 1 -----------
Menu1
Item3
1
OutputSelection3
-------- messagebox 2 ------------
Menu object data
MenuName (Built-in): Menu1
-15

MenuItem object data
Label-or-SubMenu (Built-in): OutputSelection3
Menu1->Item3
3
---------------------
When I look at the item again, it is still unchecked.

Also, is it normal that item order in Menu1 is
Item3
Item4
Item5
Item1
or is it a Win9x sorting issue?

Quote:
Also, about your PM, I think it's over my head.
You're older than me here, should have much more knowledge. Or am I an undiscovered genius? Laughing
Quote:
You can always PM me if you want to talk.
I may do that someday.
Back to top
View user's profile Send private message Yahoo Messenger
animeaime



Joined: 04 Nov 2008
Posts: 1046

PostPosted: Thu Feb 05, 2009 5:39 pm    Post subject: Reply with quote

Drugwash wrote:
You're older than me here, should have much more knowledge. Or am I an undiscovered genius?

Might be. Also, knowledge can be very specific. For example, just a little over a month ago I couldn't work the menu api, now I wrote a menu wrapper which uses menu api up the nose. So, experience doesn't mean knowledge. I may have experience in programming, but I only have experience in what I've done. I understand the menu api, as shown in this wrapper. Thanks to Lexikos, I can work with memory management (a bit), and the knowledge is applied in the Class library which this wrapper uses. I'm also great on breaking things down - it comes with being a top-down thinker. Your question is in an area that I'm not familiar with, so yeah, sadly, it's outside of my expertise so I'll be unable to help, sorry Crying or Very sad I can however help with data structures and how to "organize" necessary values - that is my specialty (and I love doing it).


As far as the Menu wrapper goes, you should check the code out. The "sorting issue" is the result of a Menu_Move call (it's suppose to do that). In the code, Menu_Move is called to move the item from the first position to the end of the list - Menu_Move("Menu1", 1, 0).

The reason why the one item is checked is because of this call, Menu, Menu1, check, Item2. There is no "automatic checking". If you want a certain menu item to toggle the checkmark when selected, you can use the code I provided. Having the menu toggle check on clicking is an "add-on", not a default - just like the normal AHK menu commands. This is me working on the assumption that you expected a "checking ability" from example given (unmodified). That example does not contain any "add-ons" such as that - just a demonstration of the library's abilities.

Also, the "debug message boxes" contain the information contained in the Menu and MenuItem objects for the given selection. The first MsgBox is AHK info for the selection, whereas the second contains the info associated with the menu / menu item (check the code out around the insertions to see what it does to set those values, and the test setup file for the functions it calls). Also, the values are just an example. You can associate any values: stings, ints, uints, etc. as well as other Class objects with a menu / menu item. Check out the discussion of my OOP (Object-Orientetd Programming) Class library for more info. Of course, you can also ask me for specific questions as there is a lot of info and ability and the website is only half-finished (but still contains a lot of info - and it's organized Very Happy ).

Drugwash wrote:
wrote:
You can always PM me if you want to talk.

I may do that someday.

Please do. I'm not sure what you're going through, but for example, I'm currently battling with depression. Now, granted it's not so bad that I can't wake up in the morning (there have been days like that), but it gets annoying the times I can't concentrate when coding. So, please don't feel that you discussing it will "burden" me, and don't feel you have to go it alone. Of course, if you feel unable to discuss your situation with a perfect stranger, on the other hand, please just ignore the last statements and treat them as a sign of my ignorance of your current position.
_________________
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
View user's profile Send private message Send e-mail
Drugwash



Joined: 07 Sep 2008
Posts: 608
Location: Ploiesti, RO

PostPosted: Thu Feb 05, 2009 6:03 pm    Post subject: Reply with quote

Quote:
This is me working on the assumption that you expected a "checking ability" from example given (unmodified). That example does not contain any "add-ons" such as that - just a demonstration of the library's abilities.
Got it now. Was precisely expecting a checking ability and I thought it wasn't working. Now we're clear. Smile

I've been providing help and support for Miranda IM for... 4 years or more so I'm pretty used to communicating with people. And I do it, whenever I feel the need to. So don't worry about that. Right now I need a beer so I'll go buy some and we'll see what comes. Wink
Back to top
View user's profile Send private message Yahoo Messenger
animeaime



Joined: 04 Nov 2008
Posts: 1046

PostPosted: Thu Feb 05, 2009 7:06 pm    Post subject: Reply with quote

Just thought of this since it might come up. Instead of showing a menu using Menu, MenuName, Show, use MI_ShowMenu(MenuNameOrHandle, x="", y="") instead. I'm going to see if I can't modify it to allow the menu to receive keystrokes and mouse clicks and responding to them. I'm not sure if it can be done, but I think it would be cool if it could, so I'm going to look into it. Since using MI_ShowMenu creates a window whose hWnd is known, I might be able to figure something out. Also, Menu, MenuName, Show WILL NOT show a menu if AHK doesn't think the menu has items. This can occur when the menu only has "standard menu" items (and nothing else). So, for general compatability, and any cool stuff I can add to the ShowMenu function, please use Lexikos' ShowMenu (like all his Menu Icon library functions, a local copy exists in MenuItem.ahk).

Update:
It looks like it's a real possibility to do this... If so, I'll also add drag/drop and other "cool features". I just tested a model for my idea. Using AHK's "ShowMenu" won't allow timer events to function (as documented). However, timer events still occur if the menu is drawn using MI_ShowMenu. Since this behavior is different than for AHK, I'll document it...somwhere on this thread - I'll add a note the my second post (where I'm putting the version info). Because timer events work, this means that such actions as calling a label with the menu open are possible. Also, as Lexikos does in the ShowMenu, mouse clicks can be sent back to AHK (that's how a selection is possible, he sends the command for menu select (like the Menu_selectMenuItem function) to AHK and AHK responds to it. Similarly, I should be able to have events setup to detect a mouse drag (which would allow me to add drag/drop support, to move the menu items on the menu - which would be an opt-in feature.) Also, keystrokes could trigger something. I'll be looking into that today and start designing what I can. I'll post a revision with any features I can conjure up.

Also, since I know it's possible, is there any features that yal would want regarding mouse clicks and keystrokes on the menu? I'm thinking something like how gui has it for controls - each menu would have a "goto label" that would trigger, which you could add your functionality to it (of course different menus could have the same goto label). Also, if drag/drop can be done, there would be a "start drag" and "end drag" event. I'll use global variables (details pending) to store info related to the operations.
_________________
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
View user's profile Send private message Send e-mail
Drugwash



Joined: 07 Sep 2008
Posts: 608
Location: Ploiesti, RO

PostPosted: Thu Feb 05, 2009 8:00 pm    Post subject: Reply with quote

I've spent $2 on this beer and you just make its effect vanish. Smile

Menu items can be marked/unmarked, this is good. Menus should be navigable through keyboard too; we have a couple of visually impaired (call'em "blind" coz that's the truth) users at Miranda IM and they need standard controls and keyboard navigation capabilities. We can't be human enough unless we think about any and all possibilities, beyond our own selfish needs.

I wonder if standard menu items (that may be ignored by the script) could automatically be replaced by custom items, keeping the original functionality (and possibly adding custom features).

I'm not sure about drag'n'drop in menus. Seems like an overkill to me but I may also overlook something. Darn, isn't anyone else here interested in this work besides me?
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 3 of 6

 
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