Re: NSTextField, drawing the text offset to the right in the field

2009-09-30 Thread Matt Neuburg
Although, to be clear, you *can* do this is in code, just not the way you
were doing it. You have to make sure you're talking to this instance at the
right moment, i.e. before the window appear but after the instance (the text
field) has been assembled by the nib. That moment, of course, is
awakeFromNib.

So, in awakeFromNib, instantiate the cell (you know, alloc-init etc.) and
set the textfield's cell - not its cell class, its *cell* - to that cell
instance:

[theTextField setCell: theCell];

If you do this in the text field's own awakeFromNib, then *all* text field's
of this class will adopt the custom cell.

[self setCell: theCell];

Or you can do it from elsewhere to specify that just *particular* text
fields should adopt the custom cell.

m.

On Tue, 29 Sep 2009 20:06:08 -0600, jon  said:
>ahh,  that was it,   thanks a lot,   that made perfect sense once i
>looked inside IB
>I was also surprised that IB knew about my custom cell class...
>
>I was thinking code code code...   and i just needed that shove in the
>correct direction...
>you made my day,  after a very long day...

>On Sep 29, 2009, at 7:58 PM, Kyle Sluder wrote:
>
>> +setCellClass: just tells the view "Hey next time you initialize
>> yourself, make a cell of this class."  Since your ImageTextField
>> instance was created inside of IB, this is never going to happen.
>> Instead you need to change the class of the cell from within IB, under
>> the Identity inspector.  It might be helpful to switch to the
>> hierarchical view so you can get easy access to the text field's cell.


-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTextField, drawing the text offset to the right in the field

2009-09-29 Thread jon
ahh,  that was it,   thanks a lot,   that made perfect sense once i  
looked inside IB

I was also surprised that IB knew about my custom cell class...

I was thinking code code code...   and i just needed that shove in the  
correct direction...

you made my day,  after a very long day...

thanks,
Jon.


On Sep 29, 2009, at 7:58 PM, Kyle Sluder wrote:


+setCellClass: just tells the view "Hey next time you initialize
yourself, make a cell of this class."  Since your ImageTextField
instance was created inside of IB, this is never going to happen.
Instead you need to change the class of the cell from within IB, under
the Identity inspector.  It might be helpful to switch to the
hierarchical view so you can get easy access to the text field's cell.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTextField, drawing the text offset to the right in the field

2009-09-29 Thread Kyle Sluder
+setCellClass: just tells the view "Hey next time you initialize
yourself, make a cell of this class."  Since your ImageTextField
instance was created inside of IB, this is never going to happen.
Instead you need to change the class of the cell from within IB, under
the Identity inspector.  It might be helpful to switch to the
hierarchical view so you can get easy access to the text field's cell.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTextField, drawing the text offset to the right in the field

2009-09-29 Thread jon

hmmm,  well i'm trying hard to do it...here is what i've done...

in a header:

IBOutlet ImageTextField *addressBar;

i've created this pointer to this instance...

and then in the awakefromNib method,  i have this...

[ImageTextField setCellClass:[ImageTextFieldCell class]];

this set's the class so it's cell is "correct"... for the class...   
but


but maybe this is too late for the instance addressBar.  which was set  
in the header and IB???


I don't know how to check this instance to see if it is using the  
custom cell,   and i don't know how to set the instance  
specifically... (if this class method didn't do it)?


Jon.







On Sep 29, 2009, at 7:06 PM, Matt Neuburg wrote:


On or about 9/29/09 4:43 PM, thus spake "jon" :

is properly using my custom textfield,  but the custom textfield  
doesn't

appear to be using the custom cell


Then you have to *make* the custom textfield use the custom cell. :)  
Use
whips and chains if necessary. Actually, I think what I said before  
may

cover this sufficiently:


On Sep 28, 2009, at 9:30 PM, Matt Neuburg wrote:
What I do is have the textfield replace its cell by a custom cell  
that
implements drawInteriorWithFrame, such as to inset its frame rect  
as it

calls super. m.


As the first part states, an instance of your cell class must *be*  
this text

field instance's cell. You have to make that happen... m.

--
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTextField, drawing the text offset to the right in the field

2009-09-29 Thread Matt Neuburg
On or about 9/29/09 4:43 PM, thus spake "jon" :

> is properly using my custom textfield,  but the custom textfield doesn't
> appear to be using the custom cell

Then you have to *make* the custom textfield use the custom cell. :) Use
whips and chains if necessary. Actually, I think what I said before may
cover this sufficiently:

> On Sep 28, 2009, at 9:30 PM, Matt Neuburg wrote:
>> What I do is have the textfield replace its cell by a custom cell that
>> implements drawInteriorWithFrame, such as to inset its frame rect as it
>> calls super. m.

As the first part states, an instance of your cell class must *be* this text
field instance's cell. You have to make that happen... m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTextField, drawing the text offset to the right in the field

2009-09-29 Thread jon

i've got something i think is close...

i've got a custom cell,  and a custom textfield,

i've got an override implementation of "drawInteriorWithFrame"  that i  
think will work.


but i'm confused as to where to call "drawInteriorWithFrame",   right  
now it is inside the custom Cell,   but the custom textfield never  
calls it as i believe it should?


right now
---
IBOutlet ImageTextField *addressBar;
---

[addressBar setStringValue:urlString];
is properly using my custom textfield,  but the custom textfield  
doesn't appear to be using the custom cell...  (or atleast the new  
drawInteriorWithFrame is not being called)


(i have not overriden the "setStringValue")  Maybe this isn't the  
right call, and it is bypassing "drawInteriorWithFrame"?


the only connection between custom textfield and the custom cell is

#import "ImageTextFieldCell.h"

 is inside the header of the custom textfield.

does there need to more connection to it?   or how would i get this  
call to the new drawInteriorWithFrame?


the running app shows the text field filled in properly (just not  
offset, as the override implementation of drawInteriorWithFrame would  
have done) ,   so it must have called the super of it somewhere.


thanks for the help in advance.
Jon.




On Sep 28, 2009, at 9:30 PM, Matt Neuburg wrote:


On Mon, 28 Sep 2009 19:37:00 -0600, jon  said:

i've got a textfield defined...
but i don't want to draw the text that is in the field right up
against the left boarder of the bounding box of this defined field in
IB,

I want to start the text like 20 pixels to the right of the left
boarder  and still have the nicely defined frame of the field in it's
original place...


What I do is have the textfield replace its cell by a custom cell that
implements drawInteriorWithFrame, such as to inset its frame rect as  
it

calls super. m.

--
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTextField, drawing the text offset to the right in the field

2009-09-28 Thread Matt Neuburg
On Mon, 28 Sep 2009 19:37:00 -0600, jon  said:
>i've got a textfield defined...
>but i don't want to draw the text that is in the field right up
>against the left boarder of the bounding box of this defined field in
>IB,
>
>I want to start the text like 20 pixels to the right of the left
>boarder  and still have the nicely defined frame of the field in it's
>original place...

What I do is have the textfield replace its cell by a custom cell that
implements drawInteriorWithFrame, such as to inset its frame rect as it
calls super. m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSTextField, drawing the text offset to the right in the field

2009-09-28 Thread jon

i've got a textfield defined...

IBOutlet NSTextField *addressBar;

but i don't want to draw the text that is in the field right up  
against the left boarder of the bounding box of this defined field in  
IB,


I want to start the text like 20 pixels to the right of the left  
boarder  and still have the nicely defined frame of the field in it's  
original place...


so far i've tried various methods,   one of them is below

NSRect newFrame = [addressBar bounds];

newFrame.size.width -= 20;
newFrame.origin.x += 20;
[addressBar displayRect:newFrame];

but haven't had any success,  I'm sure someone here knows exactly what  
i'm trying to do and knows a quick way to do it..


i've also tried this:  thinking i could get a textview back into a  
textfield...  or somehow use a textcontainer on NSTextField... with no  
success...


[addressBar setTextContainerInset:theInset];


thanks,
Jon.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com