discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Questions about NSMatrix and NSTableView


From: Fred Kiefer
Subject: Re: Questions about NSMatrix and NSTableView
Date: Fri, 11 Feb 2005 21:09:58 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040906

Hi Benoit,

Benoit Astruc wrote:
In my app I use some NSTableView, on Mac OS X, without coding anything the user can move from one cell to the other simply by pressing the down or up key. But on GNUstep it doesn't work :-(. So my question : will NSTableView in GNUstep one day have this enable by default and if not how can i do enable it ?


Could you please describe in more detail what you would expect pressing the up, down (probably also left, right) key to trigger? Normally an NSTableView is working with rows or columns, cells come only into play when you select or edit one. Are you now talking about the cell selection, which should be moved or about the row/column selection?


I have another issue with NSMatrix, I use some NSMatrix in my app with code like that :
------------------------------
    /*
     *    On affiche les informations du système sélectionné
     */
    if([defaults boolForKey: @"displayRevenus"])
    {
        /*
         *    Revenus
         */
        [matriceStatus addRow];
        if ([theSysteme revolte])
        {
            [matriceStatus putCell:
                [[[NSCell alloc] initImageCell: ledRouge] autorelease]
                                             atRow: i
                                            column: 0];
        }
        else
        {
            [matriceStatus putCell:
                [[[NSCell alloc] initImageCell: ledVerte] autorelease]
                                             atRow: i
                                            column: 0];
        }
        [matriceDivers addRow];
        tx = ([theSysteme revenus100]*100)/[rapport revenus100Total];
        [matriceDivers putCell:
            [[[NSCell alloc] initTextCell:
                [NSString stringWithFormat: @"%i %%",tx]] autorelease]
                                         atRow: i
                                        column: 0];
        [matriceSysteme addRow];
        [matriceSysteme putCell:
            [[[NSCell alloc] initTextCell: @"Revenus :"] autorelease]
                                            atRow: i
                                         column: 0];
        [matriceSysteme putCell:
[[[NSCell alloc] initTextCell: [theSysteme revenus2]] autorelease]
                                            atRow: i
                                         column: 1];
i++;
    }
----------------------

This code create the cells for one row, and in the same manner I create cells for others rows if the user prefs ask for them. You can see the result on Mac OS X here : http://benoit.astruc.free.fr/weymery/WRP/WRPsys0.4.7.png

But on GNUstep all the NSCell are created but all on the bottom of the NSMatrix and only the first created appears ??? What can I do ?



I wrote a short demo applciation to test the described behaviour and yes,the output on GNUstep does not show the new cells. The I looked up the definition of addRow in the specification:

"This method doesn t redraw the receiver. Accordingly, after calling this method you should send setNeedsDisplay (page 472) to the receiver. Your code may also need to use sizeToCells (page 855) after sending this method to resize the receiver to fit the newly added cells."

When adding these two methods after a call to addRow, my demo application behaves as expected. It may well be that Cocoa no longer follows its own specification an the calls are no longer necessary there, but I think that GNUstep should stick with the old behaviour until the specification changes. What you need to do is add two lines after each call to addRow.

[matrix sizeToFit];
[matrix setNeedsDisplay: YES];

This should do the trick on GNUstep and hopefully doesn't cause any harm on Cocoa, but who knows.

Cheers
Fred




reply via email to

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