Re: Menu wierdness
Re: Menu wierdness
- Subject: Re: Menu wierdness
- From: Vince DeMarco <email@hidden>
- Date: Wed, 15 Aug 2001 11:04:59 -0700
On Tuesday, August 14, 2001, at 09:19 PM, Byron Sinor wrote:
Hey gang,
I'm busy working on my first Cocoa app at the moment
and I'm having a
little bit of trouble getting a menu to work
properly, so I'm hoping
somebody here will be able to help me out.
The problem is really simple - I don't seem to be
able to change the
title of a menu using Interface Builder (v.2.0.1).
I have my menus for
my application, can set actions against the menu
items, can change the
menu items, but any edit of a menu title does not
propagate through to a
running application. When viewed/edited in
Interface Builder the .nib
file definitely has the correct menu titles.
Specifically I have changed "File" to "Game", but
when compiled and run
the menu is still titled "File". I also tried
replacing the File menu
completely with a new menu (also titled "Game") but
this appears as
"Submenu" in the compiled application.
What Vince told you earlier is correct, however, I
have had little success using the Inspector to fix
this problem. I took matters into my own hands and
investigated the .nib files themselves. I'm sure many
other here have done this, since its pretty simple,
but here is the solution:
The .nib file is just a package, use a control-click
to
select show package contents. Inside you'll find three
files (at least, I did). The classes.nib file is
probably class declarations, the info.nib file seems
to hold property and resource type info, and the
objects.xib is where all your interface objects are
actually described. The info.nib and object.xib files
look like "normal" XML files. The classes.nib appears
to be C code and look like its all declarations and no
implementation. Anyways, what you want to do is fiddle
with the objects.xib file. Within that file, you want
to find a tag like this:
<string name="title">Submenu</string>
Where "Submenu" could also be the name of any other
interface object you are looking to change (although,
I've only found name changing bugs effecting menus and
submenus). But, beware the possibility of name
conflicts (i.e. the name of the menu happens to be the
same as the name of a window) with other items; as
their names are also set with this kind of tag . So,
be sure to keep a backup .nib handy in case you alter
the wrong tag and get strange results. If you have
alot of name conflicts, you'll just have to learn to
read XML. :)
But this only works for carbon, and since this is the cocoa-dev mailing
list this particular fix will not work. Cuz the cocoa nib files are not
xml.
vince