discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cell editing in TableView


From: Matt Rice
Subject: Re: Cell editing in TableView
Date: Tue, 21 Nov 2006 08:13:53 -0800 (PST)

--- Guenther Noack <guenther@unix-ag.uni-kl.de> wrote:

> Hi!
> 
> I recently wrote a custom NSCell subclass to display
> and edit
> iTunes-like star ratings in a NSTableView. Apart
> from the obvious
> constructor methods, I overrode a -draw... method,
> the
> -trackMouse:at:... method and the -stopTracking:...
> method. The
> -trackMouse:at:... method just assigns the cellFrame
> to a field in the
> cell and then calls itself on the superclass, so
> that -stopTracking:...
> knows the current cell frame when it's clicked and
> can decide which star
> has been clicked.
> 
> My problem is: When putting this NSCell in a table
> row, it works as
> expected, but when I double click on it, there's
> suddenly a text field
> in top of it that allows me to change the value as
> text. I assume this
> is caused by the NSCell passing along its mouse
> events to the table row
> or the table. Do you know how to stop this text
> field from appearing?

theres 2 issues currently with using custom cells
and double click.

when you fix this one, you'll discover there is 
another, but first this issue.

theres many ways to fix this

[cell setEditable:NO];
this will cause track mouse to work, and as long as
the table column is editable the objectValue will
still be 
updated if the object value changes.
(this is an undefined behaviour, its currently the
only way to work around both issues from inside the
cell class)

respond NO for -tableView:shouldEditTableColumn:row:
fixes both, well defined

set the cell type to something non-NSTextCellType 
has the same effect as 
overridding -editWithFrame:... to do nothing
(works around only the issue you describe).

the next issue you will discover is that, after double
clicking, and -editWithFrame: is called NSTableView
refuses to draw the editable cell, because it will
potentially draw on top of the field editor.

heres a patch i proposed not so long ago for the
second issue.

http://lists.gnu.org/archive/html/gnustep-dev/2006-11/msg00041.html

it doesn't match the cocoa behaviour, 

(drawing an NSTextFieldCell on top of an active field
editor does draw over top of the field editor).

maybe they're using class introspection to not draw
NSTextFieldCells, i have no idea




 
____________________________________________________________________________________
Sponsored Link

Online degrees - find the right program to advance your career. 
www.nextag.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]