Re: Cocoa-dev Digest, Vol 4, Issue 494
Re: Cocoa-dev Digest, Vol 4, Issue 494
- Subject: Re: Cocoa-dev Digest, Vol 4, Issue 494
- From: Shilpa <email@hidden>
- Date: Mon, 28 May 2007 18:19:58 +0530
Hi David,
The following code solves your problem.
CFStringRef USLayout = CFSTR("U.S.");
KeyboardLayoutRef newKeyboardLayout;
OSStatus err;
KLGetKeyboardLayoutWithName (
USLayout,
&newKeyboardLayout);
if (nil != newKeyboardLayout)
{
//KLGetKeyboardLayoutProperty( newKeyboardLayout,
kKLGroupIdentifier, (const void**)&scriptCode );
KeyScript(smRoman);
err=KLSetCurrentKeyboardLayout (newKeyboardLayout);
KeyScript (smKeyDisableKybds);
}
And to enable all menu items use,
KeyScript(smKeyEnableKybds);
>
> Message: 5
> Date: Wed, 23 May 2007 20:53:13 -0700
> From: David Lobo <email@hidden>
> Subject: Re: Disabling items of "Input Menu"
> To: Andrew Farmer <email@hidden>
> Cc: email@hidden
> Message-ID:
> <email@hidden>
> Content-Type: text/plain; charset=ISO-8859-1
>
> 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.
>>
>>
>
>
-----------------------------------------------
Robosoft Technologies - Come home to Technology
Disclaimer: This email may contain confidential material. If you were not an intended recipient, please notify the sender and delete all copies. Emails to and from our network may be logged and monitored. This email and its attachments are scanned for virus by our scanners and are believed to be safe. However, no warranty is given that this email is free of malicious content or virus.
_______________________________________________
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