Checking For Keys
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.