nscell

How to change the focus ring color?

眉间皱痕 提交于 2019-12-11 13:42:17
问题 In the draw function of the NSImageView ,I want to set my custom focus ring color,not the default blue color.I tried as follows code NSSetFocusRingStyle(NSFocusRingOnly); [[NSColor redColor] setStroke]; NSRectFill([self bounds]); But the color is still default blue color.How can I solve this problem? update: The NSShadow class help me to accomplish adding focus ring.It's easy to change the shadow color. NSShadow *shadow = [[[NSShadow alloc] init] autorelease]; [shadow setShadowBlurRadius:5];

Change direction of disclosure triangle

戏子无情 提交于 2019-12-11 11:13:52
问题 How can I change the direction of the disclosure triangle programmatically? In Interface Builder it's possible by changing the value "Control -> Layout" from "Left to Right" or "Right to Left". I made a diff of a NIB file. The only change was NSCellFlags2 . Is this documented anywhere? 回答1: The method you’re looking for is -[NSCell setUserInterfaceLayoutDirection:] . You need to obtain a reference to the corresponding cell and then send it the appropriate message. For example, considering

What method should I call on my NSCell

纵然是瞬间 提交于 2019-12-11 02:21:31
问题 I am writing a custom NSControl with custom NSCells. It is a control, so it has to respond to the mouse. I created an NSTrackingArea over my control, implemented -mouseEntered: , -mouseExited: and -mouseMoved: . (And I will have to implement -mouseUp/Down: , but I have no idea what to do in there, so for now I haven't overridden those methods yet.) In these methods I successfully determine on which cell the mouse currently is. Now I have two questions: Is this a good approach for tracking the

What is the easiest way to custom NSTableView cell?

半世苍凉 提交于 2019-12-11 01:43:57
问题 I'm an iOS developer. I recently started my Mac project, but I found that unlike UITableViewCell, which is a subclass of UIView, the cell of NSTableView is NSCell, and I even can't create it in IB. I wonder if there are some easy ways to create subclass like NSTextFieldCell to put it into the NSTableView. Any help would be appreciated! Thanks! 回答1: Have a look at the open source PXListView class on Github This has a PXListViewCell that you can use as an example. 来源: https://stackoverflow.com

How to set background color of cell with NSButtoncell type in NSTableView?

这一生的挚爱 提交于 2019-12-09 23:41:03
问题 This is my table view delegate: - (void)tableView:(NSTableView *)tableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)tableColumn row:(int)row { id theRecord; NSMutableString *gid; theRecord = [tableDataSource objectAtIndex:row]; gid = [theRecord objectForKey:@"gid"]; if (([gid intValue] % 2) != 0) { [aCell setDrawsBackground: YES]; [aCell setBackgroundColor: [NSColor colorWithCalibratedRed: 237.0 / 255.0 green: 243.0 / 255.0 blue: 254.0 / 255.0 alpha: 1.0]]; } else { [aCell

NSTextFieldCell with Multiple Lines

℡╲_俬逩灬. 提交于 2019-12-09 17:46:33
问题 I need to show an NSTextFieldCell with multiple lines with different format on each line. Something like this: Line 1: Title Line 2: Description I subclassed NSTextFieldCell but I don't know how to go on with it. Any ideas? 回答1: First off, you don't have to subclass NSTextFieldCell to achieve this, since, as a subclass of NSCell , NSTextFieldCell inherits -setAttributedStringValue: . The string you provided can be represented as a NSAttributedString . The following code illustrates how you

NSButton gets drawn inside custom NSCell, but is not actually clickable

半腔热情 提交于 2019-12-08 06:01:43
问题 I have a NSTableView which contains my custom NSCell subclass, IconCell. The IconCell contains three elements : an image, text, and a button. Here's a simplified version of my drawing code ( closeButton is the button): - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { NSPoint cellPoint = cellFrame.origin; [controlView lockFocus]; CGFloat buttonWidth = [closeButton frame].size.width; [someNSImage drawInRect:NSMakeRect(cellPoint.x, cellPoint.y, ICON_WIDTH, ICON

NSButton gets drawn inside custom NSCell, but is not actually clickable

时间秒杀一切 提交于 2019-12-08 05:37:41
I have a NSTableView which contains my custom NSCell subclass, IconCell. The IconCell contains three elements : an image, text, and a button. Here's a simplified version of my drawing code ( closeButton is the button): - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { NSPoint cellPoint = cellFrame.origin; [controlView lockFocus]; CGFloat buttonWidth = [closeButton frame].size.width; [someNSImage drawInRect:NSMakeRect(cellPoint.x, cellPoint.y, ICON_WIDTH, ICON_HEIGHT) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES hints:nil];

Hiding the lupe icon of a NSSearchField

故事扮演 提交于 2019-12-06 13:50:36
I’m using a NSSearchField (not subclassed). When it’s not focused, the placeholderString is centered. But the lupe icon on the left appears a bit offset, so in fact the whole thing appears not to be centered. Is it possible to hide the lupe icon? There is not any direct access to the icon, so that a workaround is first access to the NSSearchField cell (casted as shown), and afterwards access to its button cell. self in this example is an instance of NSSearchField [(NSButtonCell *)[(NSSearchFieldCell *)self.cell searchButtonCell] setTransparent:YES]; Deafault Search Field: Hidden/Transparent

How to set background color of cell with NSButtoncell type in NSTableView?

一世执手 提交于 2019-12-04 20:52:01
This is my table view delegate: - (void)tableView:(NSTableView *)tableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)tableColumn row:(int)row { id theRecord; NSMutableString *gid; theRecord = [tableDataSource objectAtIndex:row]; gid = [theRecord objectForKey:@"gid"]; if (([gid intValue] % 2) != 0) { [aCell setDrawsBackground: YES]; [aCell setBackgroundColor: [NSColor colorWithCalibratedRed: 237.0 / 255.0 green: 243.0 / 255.0 blue: 254.0 / 255.0 alpha: 1.0]]; } else { [aCell setDrawsBackground: NO]; } } It works fine to display normal cell but the tableview get frozen after I