Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Blakeasd

macrumors 6502a
Original poster
Dec 29, 2009
643
0
Hello,
How can I add buttons inside a text field. I first tried to do this by dropping a button onto the text field. This worked fine, but text under it was not visible. How can I add a button in a text field like in Apple's Safari, if text is very long it doesn't go under the buttons. How can I achieve this?
Thanks
 
well to be perfectly honest, you can't read the text behind apple's buttons either. They make a white gradient that obscures text behind the button. So I'd say the easiest thing to do would be to make your own gradient, put that in the text bar and then put the button over it.

Other options that would probably work (I really only develop on the iPhone) would be subclass NSTextFieldCell or NSTextField itself. Or figure out how it determines where to stop the text and start moving it off to the left side and add a Category to NSTextField that allows you to set that property on regular NSTextFields.
 
Wirelessly posted (Mozilla/5.0 (iPod; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7)

I figured it out. I used a custom view to draw a box that looked like a text field and put it by the real text field. Then I took a button and put inside my fake text field. It was a complicated way of doing things but it worked.
 
Well I meant the blue border that selects the text box. Did you somehow receive the textField's mouse events?
 
NSTextField does have a method -setDrawsBackground:

You could drop the cell on top of the button and give the field a transparent background.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.