CPTableview not allowing re-ordering

19 views
Skip to first unread message

Simon

unread,
Sep 14, 2017, 10:38:24 AM9/14/17
to Cappuccino & Objective-J
Hi :)

So I have some (what I thought was) boilerplate code to set up a CPTableview ...

var frame  = CGRectMake(10, 10, 800, 400);
var usdWin = [[CPWindow alloc] initWithContentRect:frame 
      styleMask:CPTexturedBackgroundWindowMask |
                CPResizableWindowMask];
[usdWin setTitle:@"Markets"];
var content = [usdWin contentView];

...

_scrollUsd = [[CPScrollView alloc] initWithFrame:subFrame];
[_scrollUsd setAutohidesScrollers:YES];

_tvUsd = [[CPTableView alloc] initWithFrame:[_scrollUsd bounds]];
[_tvUsd setUsesAlternatingRowBackgroundColors:YES];

_dataUsd = [[CPArray alloc] init];
var col = [[CPTableColumn alloc] initWithIdentifier:@"market"];
[[col headerView] setStringValue:@"Market"];
[[col headerView] setNeedsDisplay:YES];
[_tvUsd addTableColumn:col];
col = [[CPTableColumn alloc] initWithIdentifier:@"price"];
[[col headerView] setStringValue:@"Price"];
[_tvUsd addTableColumn:col];
col = [[CPTableColumn alloc] initWithIdentifier:@"volume"];
[[col headerView] setStringValue:@"Volume"];
[_tvUsd addTableColumn:col];
[_tvUsd setDataSource:self];
[_tvUsd setDelegate:self];

[_scrollUsd setDocumentView:_tvUsd];
[content addSubview:_scrollUsd];

... and indeed I see the table on-screen, but I can't do things like re-order / re-size the columns. I've tried setting the relevant properties to YES (although they default to YES anyway according to the source), but it makes no difference. In the Javascript events, I can see a mouseDown event dispatched by Safari, but it doesn't seem to get picked up by the framework (there's no '>' on the event line, so there's no link through to the framework code from the event, unlike (for example) 'Styles invalidated' which links to the cursor-change in CPSursor.j as the mouse passes over the boundary of one of the columns).

There's no intervening views created that could be masking events, as far as I know. 'content' is the contentView of the window created at the top level.

It doesn't work in either Safari or Chrome, so I'm doing *something* wrong. Anyone any ideas as to what ?

Cheers
  Simon

Simon

unread,
Sep 14, 2017, 4:02:51 PM9/14/17
to Cappuccino & Objective-J
I know I'm replying to myself, here, but just in case someone else falls into this...

The reason for the problem is the window mask - setting 'CPTexturedBackgroundWindowMask' causes the table to not allow resizing/moving etc. I'm not sure if it's deprecated, there's some sort of "only use this when" condition, or it's just a case of bitrot, but setting the window flags to ...

    var usdWin = [[CPWindow alloc] initWithContentRect:frame 
             styleMask:CPTitledWindowMask |
       CPResizableWindowMask];


... solved the problem. Similarly, setting CPBorderlessBridgeWindowMask fixed it too.
Reply all
Reply to author
Forward
0 new messages