Fix responder handling in field editor

This commit is contained in:
Matthias Neeracher 2008-03-30 21:42:21 +00:00
parent 091da479ac
commit 6d7078e550
2 changed files with 1337 additions and 1317 deletions

File diff suppressed because it is too large Load Diff

View File

@ -845,7 +845,6 @@ static int8_t sSharpAcc[] = {
- (void) mouseMoved:(NSEvent *)event - (void) mouseMoved:(NSEvent *)event
{ {
NSLog(@"Moved\n");
if ([event modifierFlags] & NSAlphaShiftKeyMask) if ([event modifierFlags] & NSAlphaShiftKeyMask)
return; // Keyboard mode, ignore mouse return; // Keyboard mode, ignore mouse
@ -946,6 +945,15 @@ static int8_t sSharpAcc[] = {
return [[self editTarget] validValue:[fFieldEditor stringValue]]; return [[self editTarget] validValue:[fFieldEditor stringValue]];
} }
- (void)updateFirstResponder
{
NSWindow * win = [self window];
NSResponder * hasResponder = [win firstResponder];
if ([self editTarget])
if (hasResponder != [win fieldEditor:NO forObject:nil])
[win makeFirstResponder:fFieldEditor];
}
- (void)controlTextDidEndEditing:(NSNotification *)note - (void)controlTextDidEndEditing:(NSNotification *)note
{ {
VLEditable * editable = [self editTarget]; VLEditable * editable = [self editTarget];
@ -963,9 +971,10 @@ static int8_t sSharpAcc[] = {
[self setEditTarget:editable]; [self setEditTarget:editable];
if (editable) if (editable)
[fFieldEditor selectText:self]; [fFieldEditor selectText:self];
[[self window] performSelectorOnMainThread:@selector(makeFirstResponder:) else
withObject:(editable ? fFieldEditor : self) [[self window] makeFirstResponder:self];
waitUntilDone:NO]; [self performSelectorOnMainThread:@selector(updateFirstResponder)
withObject:nil waitUntilDone:NO];
[self setNeedsDisplay: YES]; [self setNeedsDisplay: YES];
} }