Indigo Rose Software
  #1  
Old 10-04-2005
Desmond's Avatar
Desmond Desmond is offline
Indigo Rose Staff Member
 
Join Date: Jul 2003
Posts: 628
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
Example Function Call:
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);
This function could definitely use some error-checking, but it should at least serve to get you started! Enjoy!
__________________
Setup Factory 8.0 comes with over 250 actions so you can create smaller, faster and more intelligent software installers than ever before.

WebHelp Guides: AMS | MSIFACT | SUF | TU | VP
Reply With Quote
  #2  
Old 10-04-2005
AXXESS's Avatar
AXXESS AXXESS is offline
Forum Member
 
Join Date: Nov 2001
Posts: 498
Very cool, Desmond.... just what I was looking for!
Reply With Quote
  #3  
Old 10-07-2005
rhosk's Avatar
rhosk rhosk is offline
Indigo Rose Customer
 
Join Date: Aug 2003
Location: Maine, USA
Posts: 1,692
Desmond, would this work if I just wanted to add a checkmark to an existing ID?


Quote:
Originally Posted by Desmond
The item properties table MUST contain the ID or this function will fail.
I'm guessing "no" with that statement. What I would like to do is execute a menu item and add a checkmark next to the existing item, which of course, would need a different ID for any subsequent logic. I mean, this is perfect if you only have enabled/disabled items. But, if you can't merely change the ID (or is there a way?...barring a runtime menu), then I don't see the advantage to this.

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.
__________________
Regards,

-Ron

Music | Video | Pictures
Reply With Quote
  #4  
Old 10-07-2005
rhosk's Avatar
rhosk rhosk is offline
Indigo Rose Customer
 
Join Date: Aug 2003
Location: Maine, USA
Posts: 1,692
Disregard, figured it out
__________________
Regards,

-Ron

Music | Video | Pictures
Reply With Quote
  #5  
Old 10-07-2005
Desmond's Avatar
Desmond Desmond is offline
Indigo Rose Staff Member
 
Join Date: Jul 2003
Posts: 628
Hey Rhosk,

Glad you got it working!

Were you able to use the above to add the checkbox? It *should* work.

Let me know!
__________________
Setup Factory 8.0 comes with over 250 actions so you can create smaller, faster and more intelligent software installers than ever before.

WebHelp Guides: AMS | MSIFACT | SUF | TU | VP
Reply With Quote
  #6  
Old 10-07-2005
rhosk's Avatar
rhosk rhosk is offline
Indigo Rose Customer
 
Join Date: Aug 2003
Location: Maine, USA
Posts: 1,692
Quote:
Originally Posted by Desmond
Were you able to use the above to add the checkbox? It *should* work.
Actually, it doesn't, because the ID has to exist. I just callled the table involved and changed it that way. Easy enough for what little I want to do. Nice function, though
__________________
Regards,

-Ron

Music | Video | Pictures
Reply With Quote
  #7  
Old 10-07-2005
Desmond's Avatar
Desmond Desmond is offline
Indigo Rose Staff Member
 
Join Date: Jul 2003
Posts: 628
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
And then call it:
Code:
ItemSetChecked(101, true);
The original function I wrote compares the ID you pass in the table to each ID in the table, and applies the properties table only if the ID's match. That's why it's required. If that makes any sense.

Glad you found my function useful!
__________________
Setup Factory 8.0 comes with over 250 actions so you can create smaller, faster and more intelligent software installers than ever before.

WebHelp Guides: AMS | MSIFACT | SUF | TU | VP
Reply With Quote
  #8  
Old 10-07-2005
rhosk's Avatar
rhosk rhosk is offline
Indigo Rose Customer
 
Join Date: Aug 2003
Location: Maine, USA
Posts: 1,692
Nice wrap!! Thanks for your help, I appreciate it. Have a great weekend!
__________________
Regards,

-Ron

Music | Video | Pictures
Reply With Quote
  #9  
Old 10-07-2005
Desmond's Avatar
Desmond Desmond is offline
Indigo Rose Staff Member
 
Join Date: Jul 2003
Posts: 628
Sure thing. You're most welcome.

Happy turkey day!
__________________
Setup Factory 8.0 comes with over 250 actions so you can create smaller, faster and more intelligent software installers than ever before.

WebHelp Guides: AMS | MSIFACT | SUF | TU | VP
Reply With Quote
  #10  
Old 02-26-2006
Roboblue's Avatar
Roboblue Roboblue is offline
Forum Member
 
Join Date: Dec 2003
Posts: 888
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.
Reply With Quote
  #11  
Old 02-27-2006
Desmond's Avatar
Desmond Desmond is offline
Indigo Rose Staff Member
 
Join Date: Jul 2003
Posts: 628
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.
__________________
Setup Factory 8.0 comes with over 250 actions so you can create smaller, faster and more intelligent software installers than ever before.

WebHelp Guides: AMS | MSIFACT | SUF | TU | VP
Reply With Quote
  #12  
Old 02-27-2006
Roboblue's Avatar
Roboblue Roboblue is offline
Forum Member
 
Join Date: Dec 2003
Posts: 888
Quote:
Originally Posted by Desmond
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.
Can we get a small example of one menu with a couple of submenu's?
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?
Reply With Quote
  #13  
Old 11-15-2006
usernameCasper's Avatar
usernameCasper usernameCasper is offline
Forum Member
 
Join Date: Nov 2006
Posts: 306
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
Reply With Quote
  #14  
Old 11-15-2006
usernameCasper's Avatar
usernameCasper usernameCasper is offline
Forum Member
 
Join Date: Nov 2006
Posts: 306
Found it out :

On Preload:

Code:
tblMenu = Application.GetMenu();
tblMenu[1].Enabled = false;
tblMenu[2].Enabled = false;
Application.SetMenu(tblMenu);
Greets,
Casper
Reply With Quote
  #15  
Old 11-15-2006
Roboblue's Avatar
Roboblue Roboblue is offline
Forum Member
 
Join Date: Dec 2003
Posts: 888
hey, much better than what i've been doing.
Thanx!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


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.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software