• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Checking For Keys
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Checking For Keys


  • Subject: Checking For Keys
  • From: Oliver Cameron <email@hidden>
  • Date: Sun, 20 Jun 2004 17:50:37 +0100

Hey guys,

In my NSTextView subclass, I use keyDown: to intercept the = key and do something with it.

Here is my current code for this:

[code]
- (void)keyDown:(NSEvent *)theEvent
{
unichar unicodeChar;
NSString *characters;
characters = [theEvent characters];
unicodeChar = [characters characterAtIndex:0];
if (unicodeChar == '=')
{
[super keyDown:theEvent];
NSRange selectedRange = [self selectedRange];
[self insertText:@"\"\""];
[self setSelectedRange:NSMakeRange(selectedRange.location + selectedRange.length + 1, 0)];
}
else
{
[super keyDown:theEvent];
}
}
[/code]

This code works perfect, and does what its meant to do (insert a "" and place the cursor in between) but this isn't too good in terms of usability. What I am looking to do is only insert the "" only if it is inside a "<" and not outside the ">".

Any ideas?

Thanks,
Oliver
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Checking For Keys
      • From: Allan Odgaard <email@hidden>
  • Prev by Date: Re: debugging a static variable
  • Next by Date: Re: Some Questions...
  • Previous by thread: Re: debugging a static variable
  • Next by thread: Re: Checking For Keys
  • Index(es):
    • Date
    • Thread