PDA

View Full Version : Transfer Menu Bar?



AXXESS
09-30-2005, 11:45 AM
Is there any way to move the menu bar data from project to project?

Desmond
09-30-2005, 12:12 PM
In what way?

You could use Application.GetMenu and Application.SetMenu . . .

Or do you mean from within the DE?

AXXESS
09-30-2005, 12:22 PM
In the design environment.... for example, if the same menu will be used across multiple projects. It would be nice to be able to apply the menu data from "project 1" to the menu bar in the existing "project 2"....

rhosk
09-30-2005, 12:27 PM
Make the script an external text (lua) file and use Application.LoadScript....or am I misunderstanding you?

Brett
09-30-2005, 12:47 PM
You can copy and paste menu structures between projects. Right-click on a node and select Copy.

rhosk
09-30-2005, 12:56 PM
This depends on how you create the menus. I was fixated at creating the menus at runtime, but, either way :)

AXXESS
09-30-2005, 01:29 PM
Ah. Nodes are fine... but no entire menu copy option at this time?

Maybe one for the suggestion box... :)

Roboblue
09-30-2005, 02:49 PM
I created a Menu Bar template that set the bar up for using a minimize and exit menus on the far right. Then, when I know I am going to start a project with a menu bar, I open the bar template project, save as the NEW project name I want. Then just +/- menus as I need to keep the formating correct with the # of menus and size of window. You have to do a Preview to see the format correctly.
If anyone wants it, here is the apz. it took about 30 minutes to set it up the first time.

Roboblue
09-30-2005, 03:02 PM
rhosk
Could you give an example of the script for a menu bar for creating at runtime?
Is there a way to export just the menubar script once the project has been created?

AXXESS
09-30-2005, 03:52 PM
I open the bar template project, save as the NEW project name I want

I would do that too, except I wanted to transfer a newly created menu to an existing project.

Desmond
09-30-2005, 04:04 PM
AXXESS,

Use an Application.GetMenu action (in your new project with the menu you want) to save your menu to a text file (Use a TextFile.WriteFromTable action).

Then, use an Application.SetMenu action (in your existing project you want to add the menu to) to set the menu to the structure you created in your new app (use a TextFile.ReadToTable action to get the data from the text file to a table).

Would that work for you?

Desmond.

AXXESS
09-30-2005, 05:42 PM
That'll work... :D

I'm just coming from the ctrl-c and ctrl-v school.... :cool

rhosk
10-02-2005, 10:39 AM
rhosk
Could you give an example of the script for a menu bar for creating at runtime?
Is there a way to export just the menubar script once the project has been created?

This is just another way to do it. Thanks to "Dermot" for a technical issue I had :) There's an example in the Help Guide, but I expanded on it a bit. I just like the idea of editing one script (or use it across projects, as requested in the first post). Doesn't require that the "Menu Bar" be activated under settings. The code could probably be cleaned up, but it works :D

Roboblue
10-02-2005, 04:56 PM
Good deal Rhosk
Thanx

Lorne
10-03-2005, 09:52 AM
Since copying and pasting a node works, create a temporary root node, make everything in the menu subordinate to that, and then copy and paste the root node.

Tip: if you want to preserve the clipboard data for use in another project, paste it into a text file. Then you can just copy that text into the menu editor.

Once you've copied the menu, move the original menu items out of the root menu (back to their original positions) and then delete the root node.

AXXESS
10-03-2005, 01:41 PM
That'll work too.... done! :)

Roboblue
02-08-2006, 03:04 AM
This is just another way to do it. Thanks to "Dermot" for a technical issue I had :) There's an example in the Help Guide, but I expanded on it a bit. I just like the idea of editing one script (or use it across projects, as requested in the first post). Doesn't require that the "Menu Bar" be activated under settings. The code could probably be cleaned up, but it works :D

Rhosk
I spent the last couple of days using your lua script template to build a set of 17 scripts for 17 pages. I finally got it to work, but there are some disadvantages to running script. A few have to do with building the project and renaming the resource file directory from AutoPlay to whatever.
1. You have to go into the script and change all the paths manually. The script files are external to the autorun.exe.
2. The image, flash, video, and music files used by the project exe are put into the dat01 directory to help protect them and to make them available to the exe when the resource directory has been renamed. ANY media file called from the script will have to be manually added to the build resource directory.
3. Any changes to the lua file during development will have to be made to the build lua file, also.
I am using a bmp that took me a couple of hours to make in Photoshop that I am using as an About screen. I am using WORM's popup notify plugin to bring it up from the taskbar. I am using the menu bar to call it. I have to manually add it along with the images directory because it is called by the script.
Because I have already broke the hump on the menu bar learning curve, I am going to go ahead and learn how to do runtime menus with on event script instead of .lua script files.
But, thanx for the example as it did help me out :yes
Now, if I can just master WORM's popup notify, I'll be ahead of the game :cool

Roboblue
02-26-2006, 10:39 AM
This is just another way to do it. Thanks to "Dermot" for a technical issue I had :) There's an example in the Help Guide, but I expanded on it a bit. I just like the idea of editing one script (or use it across projects, as requested in the first post). Doesn't require that the "Menu Bar" be activated under settings. The code could probably be cleaned up, but it works :D
rhosk
i have been using this example to build some fairly complex menu scripts that stretch across a lot of pages that require many different menu actions. I have gotten everything to work except this final, hopefully simple, problem.
In this example, I am using global functions called from the script loaded in the Page Preload event (have also tried it in the On Show event with same results). It has two toggle menus, On Top and Music. Each has an action that enables/disables the submenu nodes.
If just one of the menus is cycled, the other menu stays the same. But if both menus are cycled, the enable/disable toggles get messed up. If I remove either one of the menus, the remaining one works perfectly.
I don't think it has anything to do with the script, but in the g_OnUpdateMenuEnabled(CommandID,tblInfo) function (Global).
There are actions in the Project-Global, Page-Preload, On Show, and On Menu.
I would appreciate it if one of the menu bar gurus take a look at this and see if they can find the problem.
Also, I would be interested in any ideas on how to do this different. But, it has to work with the run.script method as I have built over 40 scripts for the project and will do away with the Music menu before I start all over again.

Roboblue
02-26-2006, 11:25 AM
Here are some screenies (slang copyrighted by Cory) to help show what I am talking about.
1.png - first start up, no menu actions selected, Music menu drop down
2.png - first start up, no menu actions selected, On Top menu drop down
3.png - Music-Pause menu selected, Play toggled enabled
4.png - On Top menu drop down after 3.png, both submenus enabled (On should be enabled, Off should be enabled)

Roboblue
02-26-2006, 08:49 PM
Here are some screenies (slang copyrighted by Cory) to help show what I am talking about.
1.png - first start up, no menu actions selected, Music menu drop down
2.png - first start up, no menu actions selected, On Top menu drop down
3.png - Music-Pause menu selected, Play toggled enabled
4.png - On Top menu drop down after 3.png, both submenus enabled (On should be enabled, Off should be enabled)
Rather
(On should be enabled, Off should be disabled)

rhosk
02-27-2006, 06:51 AM
This is one way to do it. Desmond created a script where you can manipulate the different table items by ID; I just modified it a bit.

rhosk
02-27-2006, 04:10 PM
Uh, Roboblue, did it help at all?

Roboblue
02-27-2006, 04:17 PM
Uh, Roboblue, did it help at all?
Yes, it helped. The only problem was passing the info to other pages. I worked out a way and will post a multiple page project in few minutes for others to see.
I have actually spent the last 2-3 hours recreating the whole menu bar. Kinda got caught up in it.
thanx rhosk and Desmond.

Roboblue
02-27-2006, 04:31 PM
Ok here is a lua script driven menu with menu enable/disable and actions passed to multiple pages.
Look in Global, Project On Start, Page Preload-On Show-On Menu, and Button on Click.
I am sure the functions could be integrated better, but this works.
Will post another variation in a minute.

Roboblue
02-27-2006, 04:41 PM
Ok here is another variation that builds the menu bar at runtime from lua script, but gets the menu actions on the Page On Menu event.
Notice that this example and the one above has the menu bar disabled in the AMS design view.
Either method works, so it's up to the developer to decide how he wants to maintain the menu action script, internal, or lua script.
Do you think this is worth putting into the examples section?
I am JUST now starting to see how this works, myself, so I think there's alot of other folks just as confused as I was. I didn't want to use the menu bar at first because of how hard it was to do any fancy rope-a-dope with it.

Roboblue
02-27-2006, 04:52 PM
Oh, and before I forget, here is the same example except not using the lua script at all. The menu bar is built on the Page Preload event and actions are on the Page On Menu event.
However the developer wants to maintain the menu bar is here in these three examples.
The Lua script method is nice because it allows an easy way to carry the menu bar project to project. It also allows you to have two or more different menu bars in the same project. Just run the script for the new situation. For EX: Going from a demo version to a regged version and needing a different sub menus.
The no script method is nice because there isn't any external script to debug.
Whatever floats your rubber ducky.