tips
[Top] [All Lists]

REALbasic Tip: For changing menus and modules, it's XML to the rescue!

To: "REALbasic Tips" <realbasic-tips at lists dot realsoftware dot com>
Subject: REALbasic Tip: For changing menus and modules, it's XML to the rescue!
From: Geoff Perlman <geoff at realsoftware dot com>
Date: Thu, 23 Oct 2003 16:34:07 -0500
This morning I was using the Menu Editor to create a submenu. Yes, I'm not only the CEO of REAL Software, I'm also a client. And I was reminded of a rather irritating oversight in the Menu Editor: you can't drag reorder items on a submenu. I had 5 or 6 submenu items and needed to add a new one to the top of the menu. Doing this was going to mean deleting all of the submenu items, creating the new one then re-creating the ones I just deleted. Bummer. Seconds before I was about to use both index fingers to delete the items in rapid fire succession, I thought there just has to be another way. The solution was XML.

I exported the menubar to XML (control-click on the menubar then choose Export Menu from the contextual menu and choose XML Project Item as the file format). Next I opened the opened the XML file in a text editor and located the submenu item that was at the top of the submenu. Even if you've never played with XML, it's easy to find menu items by searching for the menu text. Mine looked like this:

<MenuItem>
<ItemSpecialMenu>0</ItemSpecialMenu>
<ItemName>ArrangeMoveToFront</ItemName>
<ItemText>Move To Front</ItemText>
<ItemIndex>-2147483648</ItemIndex>
<ItemShortcut></ItemShortcut>
<ItemHelp></ItemHelp>
<ItemDisabledHelp></ItemDisabledHelp>
<ItemStyle>0</ItemStyle>
<TextEncoding>134217984</TextEncoding>
<ItemFlags>0</ItemFlags>
<MenuAutoEnable>1</MenuAutoEnable>
<ObjName></ObjName>
<ObjSize>80</ObjSize>
<Superclass>MenuItem</Superclass>
<IsInterface>0</IsInterface>
</MenuItem>

A menu item in XML starts with the <MenuItem> tag and ends with the </MenuItem> tag. I found the menu item by searching for the menu item name "Move to Front". You can see it above in the <ItemText> tag. I duplicated the entire block of XML for this menu item then changed the <ItemText> and <ItemName> tags. All that was left to do was save the file and drag it back into my Project window. Done.

Ever created a module with a bunch of methods and properties only to discover in hindsight that you really should have made it a class rather than a module? Again XML comes to the rescue. Just export the module to XML, open it in a text editor and change the value of the <IsClass>0</IsClass> tag from 0 to 1. Save your file and drag it back into your project. You just changed your module into a class.

Thanks to Mike Bailey for knowing our XML format better than me.
<x-tad-smaller>-- </x-tad-smaller>
Geoff Perlman
President and CEO
REAL Software, Inc.
512-328-7325 x711 (voice)
512-328-7372 (fax)
<Prev in Thread] Current Thread [Next in Thread>
  • REALbasic Tip: For changing menus and modules, it's XML to the rescue!, Geoff Perlman <=