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: Tue, 31 May 2005 00:16:15 +0200
Sorry, used wrong e-mail for sending to the cocoa-dev list.
Anfang der weitergeleiteten E-Mail: Datum: 30. Mai 2005 23:56:27 GMT+02:00 Betreff: Re: NSTextFieldCell subclass - location of text displayed
I found the solution... withing -setUpFieldEditorAttributes:, I can call NSTextView's -setTextContainerInset: to obtain the desired effect.
Thanks anyway
Hannes Am 30. Mai 2005 um 23:12 schrieb Hannes Friederich:
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