[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMenu menu position saving bug (PATCH)

From: Richard Frith-Macdonald
Subject: Re: NSMenu menu position saving bug (PATCH)
Date: Sat, 10 Jan 2004 08:59:05 +0000

On 10 Jan 2004, at 15:13, Michael Hanni wrote:

Hi there,

The menu position saving code has not worked for me for quite awhile. After being prodded by Alex I chased this bug down. Attached is a patch. Basically the problem is with this code:

return [NSString stringWithFormat: @"\033%@", [self title]]; //NSMenu.m ~155

On my machine this would return, for the Info menu, "nfo" not "\033Info",

Are you sure? On most systems just printing this string to a terminal will look like 'nfo' because the terminal driver will take the leading escape character to mean that the next character should not be displayed. Try printing to a file then editing/viewing that file with a program which displays control characters.

so the key was always nil (interestingly enough, if I manually edited the key in the defaults to be \033Info it worked properly). I changed this to:

So it sounds like the escape character was not saved into the defaults ... either a problem with the escape in the string, or a problem with converting it back to the four character sequence ('\\', '0', '3', '3') it should be coded as in the defaults database.

return [NSString stringWithFormat: @"+%@", [self title]];

and the key was saved and read correctly.

I'm not sure if this is the proper fix, but it works here.

I don't think this is a proper fix because '+' is a legal character in a menu title, so it's possible (though unlikely of course) to get two different menus saved with the same key ... I'm pretty sure that's the reason why NeXT used the escape character to separate menu titles in the key string.

More importantly, if something is going wrong with strings containing escape characters, you may have much more fundamental problems than just losing your menu location! Two places to look ... The string is initialised by code in base/Source/GSFormat.m The output conversion for the defaults database is in GSCompatibility.m (the PString() function)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]