简体   繁体   English

为什么可编辑的可可文本字段单元格不绘制阴影?

[英]Why doesn't an editable Cocoa text field cell draw a shadow?

So, it works fine if I disable editing for the textfield/textfieldcell... through code or interface builder. 因此,如果我通过代码或界面构建器禁用了对textfield / textfieldcell ...的编辑,则效果很好。

在此处输入图片说明 (notice the slight shadow) (注意轻微的阴影)

But once I make it editable ([cell setEditable:YES]) the shadow completely disappears: 但是一旦我将其设置为可编辑状态([cell setEditable:YES]),阴影就会完全消失:

在此处输入图片说明

I've tried drawing a shadow two ways: One, setting NSBackgroundStyleRaised , and two, overriding - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView to manually create a shadow. 我尝试过两种方式绘制阴影:一种是设置NSBackgroundStyleRaised ,另一种是覆盖- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView手动创建阴影。 Both styles/ways of drawing a shadow stop working once the cell is made editable. 单元格变为可编辑状态后,两种绘制阴影的样式/方式都将停止工作。 (To make it clear, the end result should be inset-looking, editable text. The pictures above only served as a demonstration.) (为了清楚起见,最终结果应该是可插入插图的可编辑文本。以上图片仅作为演示。)

Can someone tell me why? 有人可以告诉我为什么吗? And how I can get around this issue? 我该如何解决这个问题?

I think I figured out why, at least partially - 我想我至少知道了为什么-

Because I was using - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView to set the shadow, and because when editing, the field editor is also doing the drawing (and it's not going through the above mentioned method) the shadow doesn't apply to it. 因为我使用的是- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView来设置阴影,并且因为在编辑时, 字段编辑器也在绘制图形(并且没有经过上述方法)阴影不适用于它。

Confirmation on this might be nice, but for now I'm going to assume this is why the shadow isn't drawing. 对此进行确认可能很好,但是现在我要假定这就是阴影未绘制的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM