|
#1
|
||||
|
||||
|
FUNCTION: Adjust Menu Item Properties
Hello,
This function allows you to change any individual menu item's properties at runtime using only it's ID. Please note that menu items with sub-items have an ID of -1, and therefore will not work with this function. Code:
-- NAME: AdjustSubMenuProperties -- VALUES: tSubMenu: A numerically indexed menu (or sub-menu table) -- tItemProperties: A table of properties (Enabled, Checked, ID, Text, SubMenu) -- RETURNS: (table) The complete (adjusted) menu structure -- TO USE: Pass this function a table containing the project's menu (from Application.GetMenu) -- and a table containing item properties. The item properties table MUST contain the ID -- or this function will fail. function AdjustSubMenuProperties(tSubMenu, tItemProperties) for nIndex, tItem in tSubMenu do if tItem.ID == tItemProperties.ID then -- The ID's match, this is the item to change -- We need to fill in any non-included properties (so they're not changed) for sKey, vValue in tItem do if tItemProperties[sKey] == nil then -- A property existing in the menu was not passed to this function. -- assign the current value to the new property table tItemProperties[sKey] = vValue; end end -- Assign the new properties over the old ones tSubMenu[nIndex] = tItemProperties; -- Break out of the loop, we're done. break; elseif type(tItem.SubMenu) == 'table' and tItem.ID == -1 then -- The ID didn't match, and a sub-menu exists. Recurse. tSubMenu[nIndex].SubMenu = AdjustSubMenuProperties(tSubMenu[nIndex].SubMenu, tItemProperties); end end -- Return. return tSubMenu; end Code:
-- Get the current menu structure
tMenu = Application.GetMenu();
-- Adjust menu structure to disable item with ID 301 (and change it's text to 'Desmond')
tMenu = AdjustSubMenuProperties(tMenu, {ID=301, Text = "Desmond", Enabled = false});
-- Apply the new menu structure to the application
Application.SetMenu(tMenu);
|
|
#2
|
||||
|
||||
|
Very cool, Desmond.... just what I was looking for!
|
|
#3
|
||||
|
||||
|
Desmond, would this work if I just wanted to add a checkmark to an existing ID?
Quote:
PS, a nice solution would be to allow "hidden" menu items and call them when you need them. I tried to just assign an ID with blank text and that's exactly what I got for an output, lol. |
|
#4
|
||||
|
||||
|
Disregard, figured it out
|
|
#5
|
||||
|
||||
|
Hey Rhosk,
Glad you got it working! Were you able to use the above to add the checkbox? It *should* work. ![]() Let me know! |
|
#6
|
||||
|
||||
|
Quote:
|
|
#7
|
||||
|
||||
|
Oh, I think I understand.
You could wrap this into your own function like this: Code:
function ItemSetChecked(nID, bChecked)
-- Get the current menu structure
tMenu = Application.GetMenu();
-- Adjust menu structure to disable item with ID 301 (and change it's text to 'Desmond')
tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, Checked=bChecked});
-- Apply the new menu structure to the application
Application.SetMenu(tMenu);
end
Code:
ItemSetChecked(101, true); ![]() Glad you found my function useful! |
|
#8
|
||||
|
||||
|
Nice wrap!! Thanks for your help, I appreciate it. Have a great weekend!
|
|
#9
|
||||
|
||||
|
Sure thing. You're most welcome.
Happy turkey day! |
|
#10
|
||||
|
||||
|
I have seen some great menu bar examples. But one thing I need seems to be missing.
I need to have, from page to page, menus that come and go. NOT enabled/disabled. For example, on a 10 page project, 8 of them have several objects that need to be edited. On page 2, there would be 4 edit calls from the EDIT menu. On page 4, there may only be two edit calls. I can change the text and enable/disable the sub menus, but, because I can't "hide" the other two submenus, then page 4 will have two disabled (greyed) entries and two enabled entries. I don't think that is a very professional look. To get around this, I have created scripts to run on each page (menu bar disabled) that create the menu on that page. This "mostly" works. The biggest con is that there has to be a script for each page, and in my project, two scripts for each page as I have different menus for the demo version, then for the registered version. I have a total of 42 scripts. Even the most minor of changes requires all of them to be edited. I have a search and replace app I built that will make the changes in all the scripts at once, but it's a lot of maintenance. and testing. So, if there IS a way to remove/add menus (created with the Menu Bar enabled) at page runtime, I would appreciate the sharing of that information. |
|
#11
|
||||
|
||||
|
Well, I suppose you could store your menu structure in a table (or multiple tables, say one table for each sub-menu -- one for File, one for Edit) . . . then combine whatever arrays you'll use on the current page, and use an Application.SetMenu action to create the menu.
Stir and repeat for every page. |
|
#12
|
||||
|
||||
|
Quote:
I am still not real quick with the tables. And from that, could that table be put into SQLite? Also, will the menu bar have to be enabled with this method? |
|
#13
|
||||
|
||||
|
hey folks,
im starting to use this software couple days ago. i know some stuff about vbscripting and this is kind the way this software acts the same =). I did some tests with the enable/disable menubaritems, and i can put the text (strings) into a paragraph or textfield, or whatever via setProperties, but cant see a good way to enable / disable items when clicked on a button. While it can be done with setting different Text, it should also be done with set with booleans. I wonder how to do this, i observed some posts and coded for some hours, but i think it will only have to do with arrays? Dont the items in menubar, such as "File" with "ID=100", can be manipulate with some event on click like for instance a button? So it would act like this: when click on button --> menuInfo = Application.getProperties(); menuInfo1 = menuInfo.Enabled = true; And no, i dont want to set each item apart from scripting them, as it seems there is a option in the GUI, which scripting is already done when putting those new items in. Im at work, so i don't know the code exaclty what worked with the text, since i cant use a guide in the program itself. I will post it when im home. So where are those itemsProperties as it only can put in tables ? there must be something to handle properties from a single ID. For example: e_ID = 100 ==> event from ID 100 why not: menuInfo = Application.getProperties() if menuInfo.ID(100) then -- OR if menuInfo(menuInfo.ID = 100) then Application.setProperties(menuInfo.Enable = true); end Like in other program languages this isnt a hard deal ... Plsz some clearyfication. Kind regards, Casper |
|
#14
|
||||
|
||||
|
Found it out
:On Preload: Code:
tblMenu = Application.GetMenu(); tblMenu[1].Enabled = false; tblMenu[2].Enabled = false; Application.SetMenu(tblMenu); Casper |
|
#15
|
||||
|
||||
|
hey, much better than what i've been doing.
Thanx! |
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Menu Tree | Seville | AutoPlay Media Studio 6.0 | 24 | 05-03-2006 10:36 AM |
| help with ftp connect | CAI | AutoPlay Media Studio 6.0 | 0 | 09-29-2005 08:13 PM |
| Another tough one... Interaction between Web and AMS | Agent Jones | AutoPlay Media Studio 5.0 | 13 | 08-18-2005 03:10 PM |
| TUTORIAL: Showing and Hiding Objects in AutoPlay Menu Studio 3.0 | Support | AutoPlay Menu Studio 3.0 | 0 | 10-10-2002 03:39 PM |
| FAQ: AutoPlay Menu Studio 3.0 Frequently Asked Questions | Support | AutoPlay Menu Studio 3.0 | 0 | 10-10-2002 02:15 PM |
All times are GMT -6. The time now is 06:42 AM.








Linear Mode

