mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:40:48 +00:00
Implemented double click on not editable cells
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6704 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e41dd2d2a5
commit
d76cf6b79b
1 changed files with 78 additions and 5 deletions
|
@ -28,6 +28,7 @@
|
||||||
#import <AppKit/NSCell.h>
|
#import <AppKit/NSCell.h>
|
||||||
#import <AppKit/NSClipView.h>
|
#import <AppKit/NSClipView.h>
|
||||||
#import <AppKit/NSColor.h>
|
#import <AppKit/NSColor.h>
|
||||||
|
#import <AppKit/NSEvent.h>
|
||||||
#import <AppKit/NSGraphics.h>
|
#import <AppKit/NSGraphics.h>
|
||||||
#import <AppKit/NSScroller.h>
|
#import <AppKit/NSScroller.h>
|
||||||
#import <AppKit/NSTableColumn.h>
|
#import <AppKit/NSTableColumn.h>
|
||||||
|
@ -254,7 +255,6 @@
|
||||||
|
|
||||||
- (void) setDoubleAction: (SEL)aSelector
|
- (void) setDoubleAction: (SEL)aSelector
|
||||||
{
|
{
|
||||||
// TODO - implement this in mouseDown:
|
|
||||||
_doubleAction = aSelector;
|
_doubleAction = aSelector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,18 +263,38 @@
|
||||||
return _doubleAction;
|
return _doubleAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setTarget:(id)anObject
|
||||||
|
{
|
||||||
|
_target = anObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) target
|
||||||
|
{
|
||||||
|
return _target;
|
||||||
|
}
|
||||||
|
|
||||||
- (int) clickedColumn
|
- (int) clickedColumn
|
||||||
{
|
{
|
||||||
// TODO
|
return _clickedColumn;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int) clickedRow
|
- (int) clickedRow
|
||||||
{
|
{
|
||||||
// TODO
|
return _clickedRow;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The NSTableHeaderView calls this method when it receives a double click.
|
||||||
|
*/
|
||||||
|
|
||||||
|
- (void) _sendDoubleActionForColumn: (int)columnIndex
|
||||||
|
{
|
||||||
|
_clickedColumn = columnIndex;
|
||||||
|
_clickedRow = -1;
|
||||||
|
[self sendAction: _doubleAction to: _target];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*Configuration
|
*Configuration
|
||||||
*/
|
*/
|
||||||
|
@ -508,6 +528,55 @@ byExtendingSelection: (BOOL) flag
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) mouseDown: (NSEvent *)theEvent
|
||||||
|
{
|
||||||
|
NSPoint location = [theEvent locationInWindow];
|
||||||
|
NSTableColumn *tb;
|
||||||
|
int clickCount;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Pathological case -- ignore mouse down
|
||||||
|
//
|
||||||
|
if ((_numberOfRows == 0) || (_numberOfColumns == 0))
|
||||||
|
{
|
||||||
|
[super mouseDown: theEvent];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clickCount = [theEvent clickCount];
|
||||||
|
|
||||||
|
if (clickCount > 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Determine row and column which were clicked
|
||||||
|
location = [self convertPoint: location fromView: nil];
|
||||||
|
_clickedRow = [self rowAtPoint: location];
|
||||||
|
_clickedColumn = [self columnAtPoint: location];
|
||||||
|
|
||||||
|
// Selection
|
||||||
|
if (clickCount == 1)
|
||||||
|
{
|
||||||
|
// TODO: Selection
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Double-click events
|
||||||
|
if ([_delegate respondsToSelector:
|
||||||
|
@selector(tableView:shouldEditTableColumn:row:)])
|
||||||
|
{
|
||||||
|
tb = [_tableColumns objectAtIndex: _clickedColumn];
|
||||||
|
if ([_delegate tableView: self shouldEditTableColumn: tb
|
||||||
|
row: _clickedRow] == NO)
|
||||||
|
{
|
||||||
|
// Send double-action
|
||||||
|
[self sendAction: _doubleAction to: _target];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Edit the cell
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Auxiliary Components
|
* Auxiliary Components
|
||||||
*/
|
*/
|
||||||
|
@ -1057,6 +1126,7 @@ byExtendingSelection: (BOOL) flag
|
||||||
|
|
||||||
newOrigin.x = visibleRect.origin.x;
|
newOrigin.x = visibleRect.origin.x;
|
||||||
newOrigin.y = rowRect.origin.y;
|
newOrigin.y = rowRect.origin.y;
|
||||||
|
newOrigin = [self convertPoint: newOrigin toView: _super_view];
|
||||||
[(NSClipView *)_super_view scrollToPoint: newOrigin];
|
[(NSClipView *)_super_view scrollToPoint: newOrigin];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1070,6 +1140,7 @@ byExtendingSelection: (BOOL) flag
|
||||||
newOrigin.x = visibleRect.origin.x;
|
newOrigin.x = visibleRect.origin.x;
|
||||||
newOrigin.y = visibleRect.origin.y;
|
newOrigin.y = visibleRect.origin.y;
|
||||||
newOrigin.y += NSMaxY (rowRect) - NSMaxY (visibleRect);
|
newOrigin.y += NSMaxY (rowRect) - NSMaxY (visibleRect);
|
||||||
|
newOrigin = [self convertPoint: newOrigin toView: _super_view];
|
||||||
[(NSClipView *)_super_view scrollToPoint: newOrigin];
|
[(NSClipView *)_super_view scrollToPoint: newOrigin];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1094,6 +1165,7 @@ byExtendingSelection: (BOOL) flag
|
||||||
|
|
||||||
newOrigin.x = columnRect.origin.x;
|
newOrigin.x = columnRect.origin.x;
|
||||||
newOrigin.y = visibleRect.origin.y;
|
newOrigin.y = visibleRect.origin.y;
|
||||||
|
newOrigin = [self convertPoint: newOrigin toView: _super_view];
|
||||||
[(NSClipView *)_super_view scrollToPoint: newOrigin];
|
[(NSClipView *)_super_view scrollToPoint: newOrigin];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1108,6 +1180,7 @@ byExtendingSelection: (BOOL) flag
|
||||||
newOrigin.x = visibleRect.origin.x;
|
newOrigin.x = visibleRect.origin.x;
|
||||||
newOrigin.y = visibleRect.origin.y;
|
newOrigin.y = visibleRect.origin.y;
|
||||||
newOrigin.x += diff;
|
newOrigin.x += diff;
|
||||||
|
newOrigin = [self convertPoint: newOrigin toView: _super_view];
|
||||||
[(NSClipView *)_super_view scrollToPoint: newOrigin];
|
[(NSClipView *)_super_view scrollToPoint: newOrigin];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue