Re: Disabling items of "Input Menu"
Re: Disabling items of "Input Menu"
- Subject: Re: Disabling items of "Input Menu"
- From: David Lobo <email@hidden>
- Date: Wed, 23 May 2007 20:53:13 -0700
Hi Andrew,
Thanks for your reply. I am including following code in the formatter. I am having separate text fields for each part of IP Address.
Problem is when any unicode language is set in the "Input Menu", if any alphabets are typed in the IP field, then control never reaches isPartialStringValid until editing gets completed. My formatter is considering it as valid IP address (ex a12345 is valid in unicode "Input Menu"). One more problem with my formatter is that in Panther, digits can not be entered in the IP filed as [partialString intValue] returns -1. To avoid all these issues, if we can disable unicode "Input Menu" when the focus is on IP field it would be great. The same is done in System Preference when the focus is on "IP Address:" field.
-David
- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error
{
BOOL isStringValid = YES ;
if(([partialString length] > 4) || (0 > [partialString intValue]) || (255 < [partialString intValue]))
{
isStringValid = NO ;
}
else
{
NSCharacterSet *validCharacterSet = [self getValidIPAddressCharacterSet] ;
NSString *illegalString = [partialString stringByTrimmingCharactersInSet: validCharacterSet] ;
if( illegalString != nil && [illegalString length] > 0)
{
isStringValid = NO ;
}
}
return isStringValid ;
}
-(NSCharacterSet*) getValidIPAddressCharacterSet
{
NSString *validCharactersString = [NSString stringWithString:@"0123456789."] ;
NSCharacterSet *validCharacterSet = [NSCharacterSet characterSetWithCharactersInString: validCharactersString] ;
return validCharacterSet ;
}
On Wednesday, May 23, 2007, at 06:26PM, "Andrew Farmer" <email@hidden> wrote:
>On 23 May 07, at 04:26, David Lobo wrote:
>> I am developing a network based application wherein I need to use
>> IP Address field. When I enter digits in the IP field, by setting
>> unicode language in the Input Menu unicode characters are getting
>> displayed in panther. Due to this I am not able to search for the
>> IP address properly. And also my formatter fails to accept digits,
>> if the "Input Menu" is set to unicode language.
>>
>> I wanted to know how to disable the menu items of "Input Menu". In
>> system preference when we click on the "IP Addres:" field (At
>> "Configure IPv4" Manually page) all unicode menu items will be
>> disabled automatically. I need to include similar feature for my
>> application. Is there any cocoa API to implement this feature? Or
>> at least is it possible to always allow only "U.S" option in the
>> "Input Menu" for the IP address text field, so that when user
>> selects other language, again set it back to US programatically
>> when the focus is on IP address text field.
>
>You're going about this the wrong way. The input menu isn't your
>problem - all that affects is what buttons on the keyboard create
>what characters. (Some keyboard layouts may actually remap the number
>keys entirely - the original DVORAK recommended that the row be
>ordered 7531902468, and forcing the QWERTY layout could seriously
>annoy such users.) Your problem is that your field is accepting
>characters that aren't valid in an IP address. What you want is a
>custom formatter for the field that'll only accept IP addresses. Read
>Apple's "Introduction to Data Formatting Programming Guide For
>Cocoa" (available online) for more information.
>
>If you've already got a formatter, there's something wrong with it.
>Show us what you're doing.
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden