2000-09-10 Mirko Viviani <mirko.viviani@rccr.cremona.it>

* Tools/gpbs.m ([PasteboardEntry -lostOwnership]): workaround to avoid
	core dump due to NSConnection bug.

	* Source/NSWindow.m ([NSWindow -keyDown:]): discard and do not perform
	key equivalent for null character events. Triggered return key for
	default button cell.
	([NSWindow -defaultButtonCell]), ([NSWindow -setDefaultButtonCell:]),
	([NSWindow -disableKeyEquivalentForDefaultButtonCell]),
	([NSWindow -enableKeyEquivalentForDefaultButtonCell]): implemented.
	([NSWindow -dealloc]): release _defaultButtonCell

	* Headers/AppKit/NSWindow.h: added ivar and flag.

	* Source/NSOpenPanel.m ([NSOpenPanel -controlTextDidEndEditing:]),
	([NSOpenPanel -controlTextDidChange:]), ([NSOpenPanel -ok:]):
	implemented keyboard navigation.
	([NSOpenPanel -runModalForDirectory:file:types:]): do not allow
	branch selection if can't choose directories.
	([NSOpenPanel -_selectTextInColumn:]),
	([NSOpenPanel -_selectCellName:]): new private methods.
	([NSOpenPanel -filenames]): change for choose dirs.

	* Source/NSText.m ([NSText -keyDown:]): forwards text field illegal
	events to the next responder.

	* Source/NSBrowser.m ([NSBrowser -moveUp:]), ([NSBrowser -moveDown:]),
	([NSBrowser -moveLeft:]), ([NSBrowser -moveRight:]),
	([NSBrowser -keyDown:]): implemented keyboard navigation
	([NSBrowser -selectedCell]), ([NSBrowser -selectedCells]),
	([NSBrowser -columnOfMatrix:]), ([NSBrowser -selectedColumn]):
	changed return value from NSNotFound to -1 to conforms to NSMatrix
	([NSBrowser -doClick:]): fix for new return values, added support for
	multiple and branch selection.
	([NSBrowser -setLastColumn:]): mark column titles need display
	([NSBrowser -_getTitleOfColumn:]): fix for multiple selection.

	* Source/NSCell.m ([NSCell -setState:]): bug fix: set value to
	NSOnState if someone try to set NSMixedState in a two state cell.
	([NSCell -performClick:]): do not perform click if the cell is
	disabled.

	* Source/NSMatrix.m ([NSMatrix
	-_privateFrame:mode:numberOfRows:numberOfColumns:]),
	([NSMatrix -deselectAllCells]), ([NSMatrix -deselectSelectedCell]),
	([NSMatrix -selectAll:]): bug fix: set _selectRow and _selectColumn
	to -1 when no cells are selected
	([NSMatrix -performKeyEquivalent:]): saves _selectedRow and
	_selectedColumn.
	([NSMatrix -getRow:column:ofCell:]): check for null values for row and
	column.
	([NSMatrix -selectCellAtRow:column:]): deselect the current selection
	only in NSRadioModeMatrix mode.
	([NSMatrix -mouseDown:]): use the new code also for NSRadioModeMatrix
	and fix for this mode.

	* Source/NSSavePanel.m ([NSSavePanel -selectCellWithString:]): select
	text of the cell and enable okButton.
	([NSSavePanel -controlTextDidChange:]): implemented.
	([NSSavePanel -controlTextDidEndEditing:]): removed.
	([NSSavePanel -browser:createRowsForColumn:inMatrix:]): follows
	symbolic links.
	([NSSavePanel -_initWithoutGModel]): set browser doubleAction to
	performClick: of the _okButton. Set _okButton as default window button.
	Disable _okButton.
	([NSSavePanel -browser:selectCellWithString:inColumn:]),
	([NSSavePanel -selectText:]), ([NSSavePanel -keyDown:]): implemented
	keyboard navigation.
	([NSSavePanel -runModalForDirectory:file:]): enable _okButton if
	filename is valid.
	([NSSavePanel -_selectTextInColumn:]), ([NSSavePanel -_selectText:]),
	([NSSavePanel -_selectCellName:]): new private methods.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7468 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Mirko Viviani 2000-09-10 21:55:17 +00:00
parent c91af70d96
commit df00948e11
10 changed files with 1186 additions and 102 deletions

View file

@ -1,3 +1,77 @@
2000-09-10 Mirko Viviani <mirko.viviani@rccr.cremona.it>
* Tools/gpbs.m ([PasteboardEntry -lostOwnership]): workaround to avoid
core dump due to NSConnection bug.
* Source/NSWindow.m ([NSWindow -keyDown:]): discard and do not perform
key equivalent for null character events. Triggered return key for
default button cell.
([NSWindow -defaultButtonCell]), ([NSWindow -setDefaultButtonCell:]),
([NSWindow -disableKeyEquivalentForDefaultButtonCell]),
([NSWindow -enableKeyEquivalentForDefaultButtonCell]): implemented.
([NSWindow -dealloc]): release _defaultButtonCell
* Headers/AppKit/NSWindow.h: added ivar and flag.
* Source/NSOpenPanel.m ([NSOpenPanel -controlTextDidEndEditing:]),
([NSOpenPanel -controlTextDidChange:]), ([NSOpenPanel -ok:]):
implemented keyboard navigation.
([NSOpenPanel -runModalForDirectory:file:types:]): do not allow
branch selection if can't choose directories.
([NSOpenPanel -_selectTextInColumn:]),
([NSOpenPanel -_selectCellName:]): new private methods.
([NSOpenPanel -filenames]): change for choose dirs.
* Source/NSText.m ([NSText -keyDown:]): forwards text field illegal
events to the next responder.
* Source/NSBrowser.m ([NSBrowser -moveUp:]), ([NSBrowser -moveDown:]),
([NSBrowser -moveLeft:]), ([NSBrowser -moveRight:]),
([NSBrowser -keyDown:]): implemented keyboard navigation
([NSBrowser -selectedCell]), ([NSBrowser -selectedCells]),
([NSBrowser -columnOfMatrix:]), ([NSBrowser -selectedColumn]):
changed return value from NSNotFound to -1 to conforms to NSMatrix
([NSBrowser -doClick:]): fix for new return values, added support for
multiple and branch selection.
([NSBrowser -setLastColumn:]): mark column titles need display
([NSBrowser -_getTitleOfColumn:]): fix for multiple selection.
* Source/NSCell.m ([NSCell -setState:]): bug fix: set value to
NSOnState if someone try to set NSMixedState in a two state cell.
([NSCell -performClick:]): do not perform click if the cell is
disabled.
* Source/NSMatrix.m ([NSMatrix
-_privateFrame:mode:numberOfRows:numberOfColumns:]),
([NSMatrix -deselectAllCells]), ([NSMatrix -deselectSelectedCell]),
([NSMatrix -selectAll:]): bug fix: set _selectRow and _selectColumn
to -1 when no cells are selected
([NSMatrix -performKeyEquivalent:]): saves _selectedRow and
_selectedColumn.
([NSMatrix -getRow:column:ofCell:]): check for null values for row and
column.
([NSMatrix -selectCellAtRow:column:]): deselect the current selection
only in NSRadioModeMatrix mode.
([NSMatrix -mouseDown:]): use the new code also for NSRadioModeMatrix
and fix for this mode.
* Source/NSSavePanel.m ([NSSavePanel -selectCellWithString:]): select
text of the cell and enable okButton.
([NSSavePanel -controlTextDidChange:]): implemented.
([NSSavePanel -controlTextDidEndEditing:]): removed.
([NSSavePanel -browser:createRowsForColumn:inMatrix:]): follows
symbolic links.
([NSSavePanel -_initWithoutGModel]): set browser doubleAction to
performClick: of the _okButton. Set _okButton as default window button.
Disable _okButton.
([NSSavePanel -browser:selectCellWithString:inColumn:]),
([NSSavePanel -selectText:]), ([NSSavePanel -keyDown:]): implemented
keyboard navigation.
([NSSavePanel -runModalForDirectory:file:]): enable _okButton if
filename is valid.
([NSSavePanel -_selectTextInColumn:]), ([NSSavePanel -_selectText:]),
([NSSavePanel -_selectCellName:]): new private methods.
Sun Sep 10 23:33:55 2000 Nicola Pero <nicola@brainstorm.co.uk>
* Source/NSTextView.m ([-initWithFrame:textContainer:]): Fixed the

View file

@ -146,10 +146,13 @@ extern NSSize NSTokenSize;
unsigned accepts_mouse_moved:1;
unsigned has_opened:1;
unsigned has_closed:1;
unsigned default_button_cell_key_disabled:1;
} _f;
/* Reserved for back-end use */
void *_be_wind_reserved;
id _defaultButtonCell;
}
/*

View file

@ -11,6 +11,8 @@
Date: August 1998
Author: Franck Wolff <wolff@cybercable.fr>
Date: November 1999
Author: Mirko Viviani <mirko.viviani@rccr.cremona.it>
Date: September 2000
This file is part of the GNUstep GUI Library.
@ -46,6 +48,7 @@
#include <AppKit/NSMatrix.h>
#include <AppKit/NSTextFieldCell.h>
#include <AppKit/PSOperators.h>
#include <AppKit/NSEvent.h>
/* Cache */
static float scrollerWidth; // == [NSScroller scrollerWidth]
@ -314,11 +317,11 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
#if defined NSBTRACE_selectedCell || defined NSBTRACE_all
fprintf(stderr, "NSBrowser - (id)selectedCell\n");
fprintf(stderr, "----------- i: %d (%d)\n",
[self selectedColumn], NSNotFound);
[self selectedColumn], -1);
#endif
// Nothing selected
if ((i = [self selectedColumn]) == NSNotFound)
if ((i = [self selectedColumn]) == -1)
return nil;
if (!(matrix = [self matrixInColumn: i]))
@ -359,7 +362,7 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
#endif
// Nothing selected
if ((i = [self selectedColumn]) == NSNotFound)
if ((i = [self selectedColumn]) == -1)
return nil;
if (!(matrix = [self matrixInColumn: i]))
@ -400,7 +403,7 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
#endif
if (!(matrix = [self matrixInColumn: column]))
return NSNotFound;
return -1;
return [matrix selectedRow];
}
@ -805,7 +808,7 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
}
// Not found
return NSNotFound;
return -1;
}
// -------------------
@ -832,7 +835,7 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
return i;
}
return NSNotFound;
return -1;
}
// -------------------
@ -856,6 +859,7 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
_lastColumnLoaded = column;
[self _unloadFromColumn: column + 1];
[self _setColumnTitlesNeedDisplay];
}
// -------------------
@ -1925,9 +1929,12 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
- (void)doClick: (id)sender
{
int column;
NSArray *a;
BOOL shouldSelect = YES;
NSArray *a;
NSMutableArray *selectedCells;
NSEnumerator *enumerator;
NSBrowserCell *cell;
BOOL shouldSelect = YES;
int row, column, aCount, selectedCellsCount;
#if defined NSBTRACE_doClick || defined NSBTRACE_all
fprintf(stderr, "NSBrowser - (void)doClick\n");
@ -1938,48 +1945,103 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
column = [self columnOfMatrix: sender];
// If the matrix isn't ours then just return
if (column == NSNotFound)
if (column == -1)
return;
// Ask delegate if selection is ok
if ([_browserDelegate respondsToSelector:
@selector(browser:selectRow:inColumn:)])
a = [sender selectedCells];
aCount = [a count];
if(aCount == 0)
return;
selectedCells = [a mutableCopy];
enumerator = [a objectEnumerator];
while((cell = [enumerator nextObject]))
{
int row = [sender selectedRow];
shouldSelect = [_browserDelegate browser: self
selectRow: row
inColumn: column];
}
// Try the other method
else if ([_browserDelegate respondsToSelector:
@selector(browser:selectCellWithString:inColumn:)])
{
id c = [sender selectedCell];
shouldSelect = [_browserDelegate browser: self
selectCellWithString: [c stringValue]
inColumn: column];
if(_allowsBranchSelection == NO && [cell isLeaf] == NO)
{
[selectedCells removeObject:cell];
continue;
}
}
// If we should not select the cell
// then deselect it and return
if (!shouldSelect)
if([selectedCells count] == 0)
[selectedCells addObject:[sender selectedCell]];
enumerator = [a objectEnumerator];
while((cell = [enumerator nextObject]))
{
if([selectedCells containsObject:cell] == YES)
{
// Ask delegate if selection is ok
if ([_browserDelegate respondsToSelector:
@selector(browser:selectRow:inColumn:)])
{
[sender getRow:&row column:NULL ofCell:cell];
shouldSelect = [_browserDelegate browser: self
selectRow: row
inColumn: column];
}
// Try the other method
else if ([_browserDelegate
respondsToSelector:
@selector(browser:selectCellWithString:inColumn:)])
{
shouldSelect = [_browserDelegate browser: self
selectCellWithString:
[cell stringValue]
inColumn: column];
}
if (shouldSelect == NO)
[selectedCells removeObject:cell];
}
}
selectedCellsCount = [selectedCells count];
if(selectedCellsCount == 0)
{
// If we should not select the cell
// then deselect it and return
[sender deselectSelectedCell];
RELEASE(selectedCells);
return;
}
else if(selectedCellsCount < aCount)
{
[sender deselectSelectedCell];
a = [sender selectedCells];
enumerator = [selectedCells objectEnumerator];
while((cell = [enumerator nextObject]))
{
[sender getRow:&row column:NULL ofCell:cell];
[sender selectCellAtRow:row column:0];
}
if ([a count] > 0)
enumerator = [a objectEnumerator];
while((cell = [enumerator nextObject]))
{
if([selectedCells containsObject:cell] == NO)
{
[sender getRow:&row column:NULL ofCell:cell];
[sender highlightCell:NO atRow:row column:0];
}
}
}
if (selectedCellsCount > 0)
{
// Single selection
if ([a count] == 1)
if (selectedCellsCount == 1)
{
id c = [a objectAtIndex: 0];
cell = [selectedCells objectAtIndex: 0];
// If the cell is a leaf
// then unload the columns after
if ([c isLeaf])
if ([cell isLeaf])
[self setLastColumn: column];
// The cell is not a leaf so we need to load a column
else
@ -1991,15 +2053,16 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
// Load column
[self _performLoadOfColumn: column + 1];
[self _adjustMatrixOfColumn: column + 1];
[self setLastColumn: column + 1];
[self _adjustMatrixOfColumn: column + 1];
// If this column is the last visible
// then scroll right by one column
if (column == _lastVisibleColumn)
[self scrollColumnsRightBy: 1];
}
[sender scrollCellToVisibleAtRow:[sender selectedRow] column:column];
}
// Multiple selection
else
@ -2014,6 +2077,8 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
// Marks titles band as needing display.
[self _setColumnTitlesNeedDisplay];
RELEASE(selectedCells);
#if defined NSBTRACE_doClick || defined NSBTRACE_all
fprintf(stderr, "---------- (void)doClick ---------\n");
fprintf(stderr, " fvc: %d, lvc: %d, mvc: %d, lcl: %d\n",
@ -2299,7 +2364,242 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
{
}
- (void)moveUp:(id)sender
{
if(_acceptsArrowKeys == YES)
{
NSArray *cells;
NSMatrix *matrix;
NSBrowserCell *selectedCell;
BOOL firstPass = YES;
int selectedRow, oldSelectedRow, selectedColumn, numberOfRows;
selectedColumn = [self selectedColumn];
if(selectedColumn == -1)
{
matrix = [self matrixInColumn:0];
cells = [matrix cells];
numberOfRows = [cells count];
oldSelectedRow = selectedRow = numberOfRows - 1;
}
else
{
matrix = [self matrixInColumn:selectedColumn];
cells = [matrix cells];
numberOfRows = [cells count];
oldSelectedRow = selectedRow = [matrix selectedRow];
}
while(1)
{
if(selectedColumn == -1)
{
if(numberOfRows)
{
[matrix selectCellAtRow:selectedRow column:0];
[self doClick:matrix];
selectedColumn = 0;
}
else
return;
}
else
{
if(!selectedRow)
{
numberOfRows = [cells count];
if(numberOfRows <= 1)
return;
selectedRow = numberOfRows;
firstPass = NO;
}
selectedRow--;
[matrix deselectAllCells];
[matrix selectCellAtRow:selectedRow column:0];
[self doClick:matrix];
}
selectedCell = [matrix selectedCell];
if(selectedCell ||
(firstPass == NO && selectedRow == oldSelectedRow))
break;
}
if(_sendsActionOnArrowKeys == YES)
[super sendAction:_action to:_target];
}
}
- (void)moveDown:(id)sender
{
if(_acceptsArrowKeys)
{
NSArray *cells;
NSMatrix *matrix;
NSBrowserCell *selectedCell;
BOOL firstPass = YES;
int selectedRow, oldSelectedRow, selectedColumn, numberOfRows;
selectedColumn = [self selectedColumn];
if(selectedColumn == -1)
{
matrix = [self matrixInColumn:0];
oldSelectedRow = selectedRow = 0;
}
else
{
matrix = [self matrixInColumn:selectedColumn];
oldSelectedRow = selectedRow = [matrix selectedRow];
}
cells = [matrix cells];
numberOfRows = [cells count];
while(1)
{
if(selectedColumn == -1)
{
if(numberOfRows)
{
[matrix selectCellAtRow:0 column:0];
[self doClick:matrix];
selectedColumn = 0;
}
else
return;
}
else
{
selectedRow++;
if(selectedRow >= numberOfRows)
{
if(numberOfRows <= 1)
return;
selectedRow = 0;
firstPass = NO;
}
[matrix deselectAllCells];
[matrix selectCellAtRow:selectedRow column:0];
[self doClick:matrix];
}
selectedCell = [matrix selectedCell];
if(selectedCell ||
(firstPass == NO && selectedRow == oldSelectedRow))
break;
}
if(_sendsActionOnArrowKeys == YES)
[super sendAction:_action to:_target];
}
}
- (void)moveLeft:(id)sender
{
if(_acceptsArrowKeys)
{
NSMatrix *matrix;
NSCell *selectedCell;
int selectedRow, selectedColumn;
selectedColumn = [self selectedColumn];
if(selectedColumn >= 0)
{
matrix = [self matrixInColumn:selectedColumn];
selectedCell = [matrix selectedCell];
selectedRow = [matrix selectedRow];
[matrix deselectAllCells];
if(selectedColumn+1 <= [self lastColumn])
[self setLastColumn:selectedColumn];
if(_sendsActionOnArrowKeys == YES)
[super sendAction:_action to:_target];
}
}
}
- (void)moveRight:(id)sender
{
if(_acceptsArrowKeys)
{
NSMatrix *matrix;
BOOL selectFirstRow = NO;
int selectedColumn;
selectedColumn = [self selectedColumn];
if(selectedColumn == -1)
{
matrix = [self matrixInColumn:0];
if([[matrix cells] count])
{
[matrix selectCellAtRow:0 column:0];
[self doClick:matrix];
selectedColumn = 0;
}
}
else
{
matrix = [self matrixInColumn:selectedColumn];
selectFirstRow = YES;
}
if(selectFirstRow == YES)
{
matrix = [self matrixInColumn:[self lastColumn]];
if([[matrix cells] count])
{
[matrix selectCellAtRow:0 column:0];
[self doClick:matrix];
}
}
if(_sendsActionOnArrowKeys == YES)
[super sendAction:_action to:_target];
}
}
- (void) keyDown: (NSEvent *)theEvent
{
NSString *characters = [theEvent characters];
unichar character = 0;
if ([characters length] > 0)
{
character = [characters characterAtIndex: 0];
}
if(_acceptsArrowKeys)
{
switch (character)
{
case NSUpArrowFunctionKey:
[self moveUp:self];
return;
case NSDownArrowFunctionKey:
[self moveDown:self];
return;
case NSLeftArrowFunctionKey:
[self moveLeft:self];
return;
case NSRightArrowFunctionKey:
[self moveRight:self];
return;
}
}
[super keyDown: theEvent];
}
////////////////////////////////////////////////////////////////////////////////
// NSCoding protocol
@ -2687,7 +2987,24 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
// Get the selected cell
// Use its string value as the title
// Only if it is not a leaf
c = [self selectedCellInColumn: column - 1];
if(_allowsMultipleSelection == NO)
c = [self selectedCellInColumn: column - 1];
else
{
NSMatrix *matrix;
NSArray *selectedCells;
if (!(matrix = [self matrixInColumn: column - 1]))
return @"";
selectedCells = [matrix selectedCells];
if([selectedCells count] == 1)
c = [selectedCells objectAtIndex:0];
else
return @"";
}
if ([c isLeaf])
return @"";
else

View file

@ -417,9 +417,9 @@ static NSColor *shadowCol;
* differently in the future, so please use always symbolic
* constants when calling this method, this way your code won't be
* broken by changes. */
if (value > 0)
if (value > 0 || (value < 0 && _cell.allows_mixed_state == NO))
_cell.state = NSOnState;
else if (value == 0 || (_cell.allows_mixed_state == NO))
else if (value == 0)
_cell.state = NSOffState;
else
_cell.state = NSMixedState;
@ -814,6 +814,9 @@ static NSColor *shadowCol;
SEL action = [self action];
NSView *cv = [self controlView];
if(_cell.is_disabled == YES)
return;
if (cv)
{
NSRect cvBounds = [cv bounds];

View file

@ -211,7 +211,7 @@ static SEL getSel = @selector(objectAtIndex:);
}
else
{
_selectedRow = _selectedColumn = 0;
_selectedRow = _selectedColumn = -1;
}
return self;
}
@ -753,8 +753,10 @@ static SEL getSel = @selector(objectAtIndex:);
{
if (_cells[i][j] == aCell)
{
*row = i;
*column = j;
if(row)
*row = i;
if(column)
*column = j;
return YES;
}
}
@ -819,8 +821,8 @@ static SEL getSel = @selector(objectAtIndex:);
}
}
_selectedCell = nil;
_selectedRow = 0;
_selectedColumn = 0;
_selectedRow = -1;
_selectedColumn = -1;
}
- (void) deselectSelectedCell
@ -846,8 +848,8 @@ static SEL getSel = @selector(objectAtIndex:);
}
_selectedCell = nil;
_selectedRow = 0;
_selectedColumn = 0;
_selectedRow = -1;
_selectedColumn = -1;
}
- (void) selectAll: (id)sender
@ -875,8 +877,8 @@ static SEL getSel = @selector(objectAtIndex:);
else
{
_selectedCell = nil;
_selectedRow = 0;
_selectedColumn = 0;
_selectedRow = -1;
_selectedColumn = -1;
}
[self setNeedsDisplay: YES];
@ -896,9 +898,10 @@ static SEL getSel = @selector(objectAtIndex:);
/*
* We always deselect the current selection unless the new selection
* is the same.
* is the same. (in NSRadioModeMatrix)
*/
if (_selectedCell != nil && _selectedCell != aCell)
if (_selectedCell != nil && _selectedCell != aCell &&
_mode == NSRadioModeMatrix)
{
_selectedCells[_selectedRow][_selectedColumn] = NO;
[_selectedCell setState: 0];
@ -1955,7 +1958,7 @@ static SEL getSel = @selector(objectAtIndex:);
// TODO: clean this up -- remove code in excess!
// While doing that, FIXME! because all this code has bugs!
if (_mode != NSListModeMatrix)
if (_mode != NSListModeMatrix && _mode != NSRadioModeMatrix)
{
[self _mouseDownNonListMode: theEvent];
return;
@ -1966,6 +1969,16 @@ static SEL getSel = @selector(objectAtIndex:);
withPeriod: 0.05];
ASSIGN(lastEvent, theEvent);
if ((_mode == NSRadioModeMatrix) && _selectedCell != nil)
{
[_selectedCell setState: NSOffState];
[self drawCellAtRow: _selectedRow column: _selectedColumn];
[_window flushWindow];
_selectedCells[_selectedRow][_selectedColumn] = NO;
_selectedCell = nil;
_selectedRow = _selectedColumn = -1;
}
// selection involves two steps, first
// a loop that continues until the left mouse goes up; then a series of
// steps which send actions and display the cell as it should appear after
@ -2198,7 +2211,9 @@ static SEL getSel = @selector(objectAtIndex:);
if ([aCell isEnabled]
&& [[aCell keyEquivalent] isEqualToString: key])
{
NSCell *oldSelectedCell = _selectedCell;
NSCell *oldSelectedCell = _selectedCell;
int oldSelectedRow = _selectedRow;
int oldSelectedColumn = _selectedColumn;
_selectedCell = aCell;
[self highlightCell: YES atRow: i column: j];
@ -2206,6 +2221,8 @@ static SEL getSel = @selector(objectAtIndex:);
[self sendAction];
[self highlightCell: NO atRow: i column: j];
_selectedCell = oldSelectedCell;
_selectedRow = oldSelectedRow;
_selectedColumn = oldSelectedColumn;
return YES;
}

View file

@ -3,7 +3,7 @@
Standard open panel for opening files
Copyright (C) 1996 Free Software Foundation, Inc.
Copyright (C) 1996, 1998, 1999, 2000 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
Date: 1996
@ -17,6 +17,9 @@
Author: Nicola Pero <n.pero@mi.flashnet.it>
Date: October 1999 Completely Rewritten.
Author: Mirko Viviani <mirko.viviani@rccr.cremona.it>
Date: September 2000
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
@ -53,6 +56,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
// Pacify the compiler
@interface NSSavePanel (_PrivateMethods)
- (void) _resetDefaults;
- (void) _selectCellName: (NSString *)title;
@end
//
@ -82,6 +86,109 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
return YES;
}
- (void) _selectTextInColumn: (int)column
{
NSMatrix *matrix;
if(column == -1)
return;
matrix = [_browser matrixInColumn:column];
if ([_browser allowsMultipleSelection])
{
NSArray *selectedCells;
selectedCells = [matrix selectedCells];
if([selectedCells count] <= 1)
{
if(_canChooseDirectories == NO ||
[[matrix selectedCell] isLeaf] == YES)
[super _selectTextInColumn:column];
else
{
[self _selectCellName:[[_form cellAtIndex: 0] stringValue]];
[_form selectTextAtIndex:0];
[_okButton setEnabled:YES];
}
}
else
{
[_form abortEditing];
[[_form cellAtIndex: 0] setStringValue:nil];
[_form selectTextAtIndex:0];
[_form setNeedsDisplay:YES];
[_okButton setEnabled:YES];
}
}
else
{
if(_canChooseDirectories == NO || [[matrix selectedCell] isLeaf] == YES)
[super _selectTextInColumn:column];
else
{
if([[[_form cellAtIndex: 0] stringValue] length] > 0)
{
[self _selectCellName:[[_form cellAtIndex: 0] stringValue]];
[_form selectTextAtIndex:0];
[_form setNeedsDisplay:YES];
}
[_okButton setEnabled:YES];
}
}
}
- (void) _selectCellName: (NSString *)title
{
NSString *cellString;
NSArray *cells;
NSMatrix *matrix;
NSComparisonResult result;
NSRange range;
int i, titleLength, cellLength, numberOfCells;
matrix = [_browser matrixInColumn:[_browser lastColumn]];
if([matrix selectedCell])
return;
titleLength = [title length];
if(!titleLength)
return;
range.location = 0;
range.length = titleLength;
cells = [matrix cells];
numberOfCells = [cells count];
for(i = 0; i < numberOfCells; i++)
{
cellString = [[matrix cellAtRow:i column:0] stringValue];
cellLength = [cellString length];
if(cellLength < titleLength)
continue;
result = [cellString compare:title options:0 range:range];
if(result == NSOrderedSame)
{
[matrix selectCellAtRow:i column:0];
[matrix scrollCellToVisibleAtRow:i column:0];
[_okButton setEnabled:YES];
return;
}
else if(result == NSOrderedDescending)
break;
}
if(_canChooseDirectories == NO)
[_okButton setEnabled:NO];
}
@end
@implementation NSOpenPanel
@ -136,7 +243,6 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
- (void) setCanChooseDirectories: (BOOL)flag
{
_canChooseDirectories = flag;
// TODO: fix the following in NSBrowser
[_browser setAllowsBranchSelection: flag];
}
@ -201,8 +307,16 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
}
return ret;
}
else
return [NSArray arrayWithObject: [super filename]];
else
{
if (_canChooseDirectories == YES)
{
if ([_browser selectedColumn] != [_browser lastColumn])
return [NSArray arrayWithObject: [self directory]];
}
return [NSArray arrayWithObject: [super filename]];
}
}
/*
@ -241,12 +355,77 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
isDirectory: &isDir] == NO)
|| isDir)
[_okButton setEnabled: NO];
if([_browser allowsMultipleSelection] == YES)
[_browser setAllowsBranchSelection:NO];
}
return [self runModalForDirectory: path
file: name];
}
- (void) ok: (id)sender
{
NSMatrix *matrix;
NSBrowserCell *selectedCell = nil;
NSArray *selectedCells;
int selectedColumn;
selectedColumn = [_browser selectedColumn];
if(selectedColumn == -1)
return;
matrix = [_browser matrixInColumn:selectedColumn];
if([_browser allowsMultipleSelection] == YES)
{
selectedCells = [matrix selectedCells];
if(selectedColumn == [_browser lastColumn] &&
[selectedCells count] == 1)
selectedCell = [selectedCells objectAtIndex:0];
}
else
{
if(_canChooseDirectories == NO || selectedColumn == [_browser lastColumn])
selectedCell = [matrix selectedCell];
}
if(selectedCell)
{
if ([selectedCell isLeaf] == NO)
{
[_browser doClick:matrix];
return;
}
}
ASSIGN (_directory, [_browser pathToColumn:[_browser lastColumn]]);
if(selectedCell)
ASSIGN (_fullFileName, [_directory stringByAppendingPathComponent:
[selectedCell stringValue]]);
else
ASSIGN (_fullFileName, nil);
if (_delegateHasValidNameFilter)
{
NSEnumerator *enumerator;
NSArray *filenames = [self filenames];
NSString *filename;
enumerator = [filenames objectEnumerator];
while((filename = [enumerator nextObject]))
{
if (![_delegate panel:self isValidFilename: filename])
return;
}
}
_OKButtonPressed = YES;
[NSApp stopModal];
[self close];
}
/*
* NSCoding protocol
*/
@ -284,13 +463,14 @@ selectCellWithString: (NSString *)title
{
NSMatrix *m;
NSArray *c;
BOOL isLeaf;
m = [_browser matrixInColumn: column];
c = [m selectedCells];
if ([c count] == 1)
{
BOOL isLeaf = [[c objectAtIndex: 0] isLeaf];
isLeaf = [[c objectAtIndex: 0] isLeaf];
if (_canChooseDirectories == NO)
{
@ -316,3 +496,133 @@ selectCellWithString: (NSString *)title
}
}
@end
//
// NSForm delegate methods
//
@interface NSOpenPanel (FormDelegate)
- (void) controlTextDidEndEditing: (NSNotification*)aNotification;
- (void) controlTextDidChange: (NSNotification *)aNotification;
@end
@implementation NSOpenPanel (FormDelegate)
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
{
NSMatrix *matrix;
NSBrowserCell *selectedCell;
matrix = [_browser matrixInColumn:[_browser lastColumn]];
selectedCell = [matrix selectedCell];
if (!selectedCell)
[_form selectTextAtIndex:0];
}
- (void) controlTextDidChange: (NSNotification *)aNotification;
{
NSString *s, *selectedString;
NSArray *cells;
NSMatrix *matrix;
NSCell *selectedCell;
int i, sLength, cellLength, selectedRow;
NSComparisonResult result;
NSRange range;
matrix = [_browser matrixInColumn:[_browser lastColumn]];
s = [[[aNotification userInfo] objectForKey:@"NSFieldEditor"] string];
sLength = [s length];
range.location = 0;
range.length = sLength;
if(sLength == 0)
{
[matrix deselectAllCells];
if(_canChooseDirectories == NO)
[_okButton setEnabled:NO];
return;
}
selectedCell = [matrix selectedCell];
selectedString = [selectedCell stringValue];
selectedRow = [matrix selectedRow];
cells = [matrix cells];
if(selectedString)
{
cellLength = [selectedString length];
if(cellLength < sLength)
range.length = cellLength;
result = [selectedString compare:s options:0 range:range];
if(result == NSOrderedSame)
return;
else if(result == NSOrderedAscending)
result = NSOrderedDescending;
else if(result == NSOrderedDescending)
result = NSOrderedAscending;
range.length = sLength;
}
else
result = NSOrderedDescending;
if(result == NSOrderedDescending)
{
int numberOfCells = [cells count];
for(i = selectedRow+1; i < numberOfCells; i++)
{
selectedString = [[matrix cellAtRow:i column:0] stringValue];
cellLength = [selectedString length];
if(cellLength < sLength)
continue;
result = [selectedString compare:s options:0 range:range];
if(result == NSOrderedSame)
{
[matrix deselectAllCells];
[matrix selectCellAtRow:i column:0];
[matrix scrollCellToVisibleAtRow:i column:0];
[_okButton setEnabled:YES];
return;
}
else if(result == NSOrderedDescending)
break;
}
}
else
{
for(i = selectedRow; i >= 0; --i)
{
selectedString = [[matrix cellAtRow:i column:0] stringValue];
cellLength = [selectedString length];
if(cellLength < sLength)
continue;
result = [selectedString compare:s options:0 range:range];
if(result == NSOrderedSame)
{
[matrix deselectAllCells];
[matrix selectCellAtRow:i column:0];
[matrix scrollCellToVisibleAtRow:i column:0];
[_okButton setEnabled:YES];
return;
}
else if(result == NSOrderedAscending)
break;
}
}
[matrix deselectAllCells];
if(_canChooseDirectories == NO)
[_okButton setEnabled:NO];
}
@end /* NSOpenPanel */

View file

@ -3,7 +3,7 @@
Standard save panel for saving files
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
Author: Jonathan Gapen <jagapen@smithlab.chem.wisc.edu>
Date: 1999
@ -11,6 +11,9 @@
Author: Nicola Pero <n.pero@mi.flashnet.it>
Date: 1999
Author: Mirko Viviani <mirko.viviani@rccr.cremona.it>
Date: September 2000
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
@ -41,6 +44,7 @@
#include <AppKit/NSImageView.h>
#include <AppKit/NSMatrix.h>
#include <AppKit/NSSavePanel.h>
#include <AppKit/NSOpenPanel.h>
#include <AppKit/NSTextField.h>
#include <AppKit/NSWorkspace.h>
#include <Foundation/NSException.h>
@ -76,6 +80,8 @@ static BOOL _gs_display_reading_progress = NO;
- (void) _setHomeDirectory;
- (void) _mountMedia;
- (void) _unmountMedia;
- (void) _selectTextInColumn: (int)column;
- (void) _selectCellName: (NSString *)title;
@end /* NSSavePanel (PrivateMethods) */
@ -117,13 +123,13 @@ static BOOL _gs_display_reading_progress = NO;
r = NSMakeRect (8, 68, 292, 177);
_browser = [[NSBrowser alloc] initWithFrame: r];
[_browser setDelegate: self];
[_browser setDoubleAction: @selector (ok:)];
[_browser setTarget: self];
[_browser setMaxVisibleColumns: 2];
[_browser setHasHorizontalScroller: YES];
[_browser setAllowsMultipleSelection: NO];
[_browser setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable];
[_browser setTag: NSFileHandlingPanelBrowser];
[_browser setAction:@selector(_selectText:)];
[_browser setTarget:self];
[_topView addSubview: _browser];
[_browser release];
@ -206,12 +212,17 @@ static BOOL _gs_display_reading_progress = NO;
[_okButton setImagePosition: NSNoImage];
[_okButton setTarget: self];
[_okButton setAction: @selector(ok:)];
[_okButton setEnabled: NO];
// [_okButton setNextKeyView: _form];
[_okButton setAutoresizingMask: NSViewMinXMargin];
[_okButton setTag: NSFileHandlingPanelOKButton];
[_bottomView addSubview: _okButton];
[self setDefaultButtonCell:[_okButton cell]];
[_okButton release];
[_browser setDoubleAction:@selector(performClick:)];
[_browser setTarget:_okButton];
r = NSMakeRect (8, 261, 48, 48);
button = [[NSButton alloc] initWithFrame: r];
image = [[NSApplication sharedApplication] applicationIconImage];
@ -247,6 +258,7 @@ static BOOL _gs_display_reading_progress = NO;
[self setContentSize: NSMakeSize (384, 426)];
[super setTitle: @""];
return self;
}
@ -287,6 +299,90 @@ static BOOL _gs_display_reading_progress = NO;
[[NSWorkspace sharedWorkspace] unmountAndEjectDeviceAtPath: [self directory]];
}
- (void) _selectTextInColumn: (int)column
{
NSMatrix *matrix;
NSBrowserCell *selectedCell;
BOOL isLeaf;
if(column == -1)
return;
matrix = [_browser matrixInColumn:column];
selectedCell = [matrix selectedCell];
isLeaf = [selectedCell isLeaf];
if (isLeaf)
{
[[_form cellAtIndex: 0] setStringValue: [selectedCell stringValue]];
[_form selectTextAtIndex:0];
[_form setNeedsDisplay:YES];
[_okButton setEnabled:YES];
}
else
{
if([[[_form cellAtIndex: 0] stringValue] length] > 0)
{
[_okButton setEnabled:YES];
[self _selectCellName:[[_form cellAtIndex: 0] stringValue]];
[_form selectTextAtIndex:0];
[_form setNeedsDisplay:YES];
}
else
[_okButton setEnabled:NO];
}
}
- (void) _selectText: (id)sender
{
[self _selectTextInColumn:[_browser selectedColumn]];
}
- (void) _selectCellName: (NSString *)title
{
NSString *cellString;
NSArray *cells;
NSMatrix *matrix;
NSComparisonResult result;
NSRange range;
int i, titleLength, cellLength, numberOfCells;
matrix = [_browser matrixInColumn:[_browser lastColumn]];
if([matrix selectedCell])
return;
titleLength = [title length];
if(!titleLength)
return;
range.location = 0;
range.length = titleLength;
cells = [matrix cells];
numberOfCells = [cells count];
for(i = 0; i < numberOfCells; i++)
{
cellString = [[matrix cellAtRow:i column:0] stringValue];
cellLength = [cellString length];
if(cellLength != titleLength)
continue;
result = [cellString compare:title options:0 range:range];
if(result == NSOrderedSame)
{
[matrix selectCellAtRow:i column:0];
[matrix scrollCellToVisibleAtRow:i column:0];
[_okButton setEnabled:YES];
return;
}
else if(result == NSOrderedDescending)
break;
}
}
@end /* NSSavePanel (PrivateMethods) */
//
@ -568,9 +664,18 @@ static BOOL _gs_display_reading_progress = NO;
ASSIGN (_directory, path);
ASSIGN (_fullFileName, [path stringByAppendingPathComponent: filename]);
[_browser setPath: _fullFileName];
[self _selectCellName:filename];
[[_form cellAtIndex: 0] setStringValue: filename];
[_form selectTextAtIndex:0];
[_form setNeedsDisplay: YES];
if([self isKindOfClass:[NSOpenPanel class]] == NO)
{
if([filename isEqual:@""] == NO)
[_okButton setEnabled:YES];
}
/*
* We need to take care of the possibility of
* the panel being aborted. We return NSCancelButton
@ -622,6 +727,22 @@ static BOOL _gs_display_reading_progress = NO;
- (void) ok: (id)sender
{
NSMatrix *matrix;
NSBrowserCell *selectedCell;
matrix = [_browser matrixInColumn:[_browser lastColumn]];
selectedCell = [matrix selectedCell];
if (selectedCell && [selectedCell isLeaf] == NO)
{
[_browser doClick:matrix];
return;
}
ASSIGN (_directory, [_browser pathToColumn:[_browser lastColumn]]);
ASSIGN (_fullFileName, [_directory stringByAppendingPathComponent:
[[_form cellAtIndex:0] stringValue]]);
if (_delegateHasValidNameFilter)
if (![_delegate panel:self isValidFilename: [self filename]])
return;
@ -633,7 +754,100 @@ static BOOL _gs_display_reading_progress = NO;
- (void) selectText: (id)sender
{
// TODO
NSEvent *theEvent = [self currentEvent];
NSString *characters = [theEvent characters], *keyString;
unichar character = 0;
if ([characters length] > 0)
{
character = [characters characterAtIndex: 0];
}
switch (character)
{
case NSTabCharacter:
if ([theEvent modifierFlags] & NSShiftKeyMask)
{
character = NSUpArrowFunctionKey;
keyString = [NSString stringWithCharacters:&character
length:1];
}
else
{
character = NSDownArrowFunctionKey;
keyString = [NSString stringWithCharacters:&character
length:1];
}
[[_form cellAtIndex:0] setStringValue:nil];
[_browser keyDown:[NSEvent keyEventWithType:NSKeyDown
location:[theEvent locationInWindow]
modifierFlags:0
timestamp:[theEvent timestamp]
windowNumber:[theEvent windowNumber]
context:[theEvent context]
characters:keyString
charactersIgnoringModifiers:keyString
isARepeat:NO
keyCode:0]];
break;
case NSUpArrowFunctionKey:
case NSDownArrowFunctionKey:
case NSLeftArrowFunctionKey:
case NSRightArrowFunctionKey:
[_form abortEditing];
[[_form cellAtIndex:0] setStringValue:nil];
[_browser keyDown:theEvent];
break;
}
}
- (void) keyDown: (NSEvent *)theEvent
{
NSString *characters = [theEvent characters];
unichar character = 0;
if ([characters length] > 0)
{
character = [characters characterAtIndex: 0];
}
switch (character)
{
case NSTabCharacter:
case NSUpArrowFunctionKey:
case NSDownArrowFunctionKey:
case NSLeftArrowFunctionKey:
case NSRightArrowFunctionKey:
[self selectText:self];
return;
case NSEnterCharacter:
case NSFormFeedCharacter:
case NSCarriageReturnCharacter:
if([_okButton isEnabled] == YES)
{
NSMatrix *matrix;
int selectedColumn;
selectedColumn = [_browser selectedColumn];
if(selectedColumn == -1 || selectedColumn != [_browser lastColumn])
break;
matrix = [_browser matrixInColumn:selectedColumn];
if([[matrix selectedCell] isLeaf] == NO)
{
[_form abortEditing];
[[_form cellAtIndex: 0] setStringValue: nil];
}
}
break;
}
[super keyDown:theEvent];
}
- (void) setDelegate: (id)aDelegate
@ -699,33 +913,44 @@ selectCellWithString: (NSString*)title
createRowsForColumn: (int)column
inMatrix: (NSMatrix*)matrix
{
NSString *path, *file, *pathAndFile, *extension, *h;
NSArray *files, *hiddenFiles;
unsigned i, count, addedRows;
BOOL exists, isDir;
NSBrowserCell *cell;
NSString *path, *pathTmp, *file, *pathAndFile, *extension, *h;
NSArray *files, *hiddenFiles;
unsigned i, count, addedRows;
BOOL exists, isDir;
NSBrowserCell *cell;
// _gs_display_reading_progress variables
unsigned reached_frac = 0;
unsigned base_frac = 1;
BOOL display_progress = NO;
NSString* progressString = nil;
unsigned reached_frac = 0;
unsigned base_frac = 1;
BOOL display_progress = NO;
NSString *progressString = nil;
/* We create lot of objects in this method, so we use a pool */
NSAutoreleasePool *pool;
NSAutoreleasePool *pool;
NSDirectoryEnumerator *dirEnum;
IMP nxtImp;
IMP addImp;
pool = [NSAutoreleasePool new];
path = [_browser pathToColumn: column];
files = [_fm directoryContentsAtPath: path];
dirEnum = AUTORELEASE([[NSDirectoryEnumerator alloc]
initWithDirectoryPath: path
recurseIntoSubdirectories: NO
followSymlinks: NO
prefixFiles: NO]);
files = [NSMutableArray arrayWithCapacity: 16];
nxtImp = [dirEnum methodForSelector: @selector(nextObject)];
addImp = [files methodForSelector: @selector(addObject:)];
while ((pathTmp = (*nxtImp)(dirEnum, @selector(nextObject))) != nil)
(*addImp)(files, @selector(addObject:), pathTmp);
// Remove hidden files
h = [path stringByAppendingPathComponent: @".hidden"];
h = [NSString stringWithContentsOfFile: h];
hiddenFiles = [h componentsSeparatedByString: @"\n"];
if (hiddenFiles)
{
files = [NSMutableArray arrayWithArray: files];
[(NSMutableArray*)files removeObjectsInArray: hiddenFiles];
}
[(NSMutableArray*)files removeObjectsInArray: hiddenFiles];
count = [files count];
@ -869,25 +1094,43 @@ selectCellWithString: (NSString*)title
NSMatrix *m;
BOOL isLeaf;
NSString *path;
NSEvent *event;
m = [sender matrixInColumn: column];
isLeaf = [[m selectedCell] isLeaf];
path = [sender pathToColumn: column];
if([self isKindOfClass:[NSOpenPanel class]] == NO)
{
event = [self currentEvent];
if(event && [event type] == NSKeyDown && isLeaf == YES)
{
NSString *characters = [event characters];
unichar character = 0;
if ([characters length] > 0)
{
character = [characters characterAtIndex: 0];
}
if(character != NSRightArrowFunctionKey ||
[sender selectedRowInColumn:column] != 0)
return NO;
}
}
if (isLeaf)
{
ASSIGN (_directory, path);
ASSIGN (_fullFileName, [path stringByAppendingPathComponent: title]);
[[_form cellAtIndex: 0] setStringValue: title];
[_form setNeedsDisplay: YES];
}
else
{
ASSIGN (_directory, [path stringByAppendingPathComponent: title]);
ASSIGN (_fullFileName, nil);
[[_form cellAtIndex: 0] setStringValue: @""];
[_form setNeedsDisplay: YES];
}
[self _selectTextInColumn:column];
return YES;
}
@ -904,26 +1147,102 @@ selectCellWithString: (NSString*)title
// NSForm delegate methods
//
@interface NSSavePanel (FormDelegate)
- (void) controlTextDidEndEditing: (NSNotification*)aNotification;
- (void) controlTextDidChange: (NSNotification *)aNotification;
@end
@implementation NSSavePanel (FormDelegate)
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
- (void) controlTextDidChange: (NSNotification *)aNotification;
{
NSString *s;
NSString *s, *selectedString;
NSArray *cells;
NSMatrix *matrix;
NSCell *selectedCell;
int i, sLength, cellLength, selectedRow;
NSComparisonResult result;
NSRange range;
s = [self directory];
s = [s stringByAppendingPathComponent: [[_form cellAtIndex: 0] stringValue]];
if (1) // TODO: condition when the filename is acceptable
matrix = [_browser matrixInColumn:[_browser lastColumn]];
s = [[[aNotification userInfo] objectForKey:@"NSFieldEditor"] string];
sLength = [s length];
range.location = 0;
range.length = sLength;
if(sLength == 0)
{
ASSIGN (_fullFileName, s);
[_browser setPath: s];
[matrix deselectAllCells];
[_okButton setEnabled:NO];
return;
}
else // typed filename is not acceptable
selectedCell = [matrix selectedCell];
selectedString = [selectedCell stringValue];
selectedRow = [matrix selectedRow];
cells = [matrix cells];
if(selectedString)
{
// TODO
result = [s compare:selectedString options:0 range:range];
if(result == NSOrderedSame)
return;
}
else
result = NSOrderedDescending;
if(result == NSOrderedDescending)
{
int numberOfCells = [cells count];
for(i = selectedRow+1; i < numberOfCells; i++)
{
selectedString = [[matrix cellAtRow:i column:0] stringValue];
cellLength = [selectedString length];
if(cellLength != sLength)
continue;
result = [selectedString compare:s options:0 range:range];
if(result == NSOrderedSame)
{
[matrix deselectAllCells];
[matrix selectCellAtRow:i column:0];
[matrix scrollCellToVisibleAtRow:i column:0];
[_okButton setEnabled:YES];
return;
}
else if(result == NSOrderedDescending)
break;
}
}
else
{
for(i = selectedRow; i >= 0; --i)
{
selectedString = [[matrix cellAtRow:i column:0] stringValue];
cellLength = [selectedString length];
if(cellLength != sLength)
continue;
result = [selectedString compare:s options:0 range:range];
if(result == NSOrderedSame)
{
[matrix deselectAllCells];
[matrix selectCellAtRow:i column:0];
[matrix scrollCellToVisibleAtRow:i column:0];
[_okButton setEnabled:YES];
return;
}
else if(result == NSOrderedAscending)
break;
}
}
[matrix deselectAllCells];
[_okButton setEnabled:YES];
}
@end /* NSSavePanel */

View file

@ -2389,6 +2389,29 @@ static NSNotificationCenter *nc;
else
{
[self interpretKeyEvents: [NSArray arrayWithObject: theEvent]];
if (_tf.is_field_editor)
{
NSString *characters = [theEvent characters];
unichar character = 0;
if ([characters length] > 0)
{
character = [characters characterAtIndex: 0];
}
switch (character)
{
case NSUpArrowFunctionKey:
case NSDownArrowFunctionKey:
case NSTabCharacter:
case NSEnterCharacter:
case NSFormFeedCharacter:
case NSCarriageReturnCharacter:
[super keyDown:theEvent];
break;
}
}
}
}

View file

@ -545,6 +545,7 @@ static NSMapTable* windowmaps = NULL;
TEST_RELEASE(_windowTitle);
TEST_RELEASE(_rectsBeingDrawn);
TEST_RELEASE(_initialFirstResponder);
TEST_RELEASE(_defaultButtonCell);
/*
* FIXME This should not be necessary - the views should have removed
@ -1989,7 +1990,21 @@ resetCursorRectsForView(NSView *theView)
}
return;
}
// FIXME: The return key should trigger the default botton
if(character == NSEnterCharacter ||
character == NSFormFeedCharacter ||
character == NSCarriageReturnCharacter)
{
if(_defaultButtonCell && _f.default_button_cell_key_disabled == NO)
{
[_defaultButtonCell performClick:self];
return;
}
}
// Discard null character events such as a Shift event after a tab key
if([characters length] == 0)
return;
// Try to process the event as a key equivalent
// without Command having being pressed
@ -3056,23 +3071,23 @@ resetCursorRectsForView(NSView *theView)
- (NSButtonCell*) defaultButtonCell
{
// FIXME: Method is missing
return nil;
return _defaultButtonCell;
}
- (void) setDefaultButtonCell: (NSButtonCell*)aButtonCell
{
// FIXME: Method is missing
ASSIGN(_defaultButtonCell, aButtonCell);
_f.default_button_cell_key_disabled = NO;
}
- (void) disableKeyEquivalentForDefaultButtonCell
{
// FIXME: Method is missing
_f.default_button_cell_key_disabled = YES;
}
- (void) enableKeyEquivalentForDefaultButtonCell
{
// FIXME: Method is missing
_f.default_button_cell_key_disabled = NO;
}
/*

View file

@ -436,7 +436,10 @@ NSMutableDictionary *pasteboards = nil;
if (wantsChangedOwner)
{
[a removeObject: owner];
/* workaround for NSConnection/NSDistantObject bug with methods
* like (SEL)methodForSelector:
* [a removeObject: owner]; */
[a removeObjectAtIndex:0];
[owner pasteboardChangedOwner: pboard];
}