简体   繁体   中英

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.

在此处输入图片说明 (notice the slight shadow)

But once I make it editable ([cell setEditable:YES]) the shadow completely disappears:

在此处输入图片说明

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. 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.

Confirmation on this might be nice, but for now I'm going to assume this is why the shadow isn't drawing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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