Re: NSTextFieldCell subclass - location of text displayed
Re: NSTextFieldCell subclass - location of text displayed
- Subject: Re: NSTextFieldCell subclass - location of text displayed
- From: Hannes Friederich <email@hidden>
- Date: Mon, 30 May 2005 23:12:26 +0200
Am 30. Mai 2005 um 22:41 schrieb j o a r:
On 30 maj 2005, at 22.10, Hannes Friederich wrote:
I'm trying to implement a subclass of NSTextFieldCell which draws its text at a different location. I actually want to add some image WITHIN the cells borders, similar to the address field of Safari. Hovewer, I cannot find any method to tell the NSText subsystem (which does the actual drawing), to draw the text at a different place than the default one.
You can subclass a cell and call super with a modified frame in the drawing method "drawInteriorWithFrame:inView:", that should allow you to offset the drawing of the text. In that same method you can also draw your image. There are probably other methods that you need to override to make the implementation work like in Safari, but that should at least be able to get you started. I'm also sure that if you look around, in the list archives or on the web, you'll find more concrete examples of how to implement custom drawing in a NSCell subclass.
j o a r
No, unfortunately this doesn't work. The displayed Text isn't drawed by the NSTextFieldCell itself, but using the window's fieldEditor NSTextView instance. Thus, when entering text, no call is made to "-drawInteriorWithFrame:inView: " at all. In addition, changing the rect sent to this method only causes the NSTextFields interior border to displayed at another location, but that's not what I want.
Hannes |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden