Overriding NSCell's editWithFrame:...

  • Hello all,

    I'm writing my own NSCell and I want to be able to edit my cell so I
    would like to learn the proper way of implementing this method
    (editWithFrame:inView:editor:delegate:event:). I cannot really
    understand what this method is supposed to do. I'm deliberately not
    subclassing NSTextFieldCell to use it's implementation of this
    method. So what am I supposed to do in this method? I can get the
    text for this cell and also modify the rectangle to match my text but
    how do I display the editing rectangle and everything else? Has
    anyone actually overridden this method without using the super
    implementation?

    Thanks,
    David
  • I think you need to read up on the window's fieldEditor.

    Mike.

    On 3 Oct 2006, at 02:26, David Aames wrote:

    > Hello all,
    >
    > I'm writing my own NSCell and I want to be able to edit my cell so
    > I would like to learn the proper way of implementing this method
    > (editWithFrame:inView:editor:delegate:event:). I cannot really
    > understand what this method is supposed to do. I'm deliberately not
    > subclassing NSTextFieldCell to use it's implementation of this
    > method. So what am I supposed to do in this method? I can get the
    > text for this cell and also modify the rectangle to match my text
    > but how do I display the editing rectangle and everything else? Has
    > anyone actually overridden this method without using the super
    > implementation?
    >
    > Thanks,
    > David
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/mike.abdullah%
    > 40gmail.com
    >
    > This email sent to <mike.abdullah...>
  • I have to agree with you, Apple's docs aren;t too amazing on this
    topic.  I shall (attempt!) to explain:

    Basically, when you edit some text, you use an NSTextView.  However,
    imagine you have 50 or so NSTextViews in your app, it will get bogged
    down quite a bit!

    So instead, we have NSTextField which is more "lightweight."

    Additionally, every window has a Field Editor which is a single
    instance of NSTextView.

    When an NSTextFieldCell (or similar class) wants to edit some text,
    it gets the field editor from the window and positions it above
    itself.  The user types into this NSTextView, and it is this which
    provides the focus ring above the control.

    So, in your method, you basically need to get the field editor from
    the window and make it a subview of your controlview.

    Mike.

    On 3 Oct 2006, at 17:53, David Aames wrote:

    > Hello Mike,
    >
    > I did and it included just general information and nothing specific
    > on implementing editWithFrame: from scratch.
    >
    > Thanks
    >
    > On 3 Oct 2006, at 11:53, Mike Abdullah wrote:
    >
    >> I think you need to read up on the window's fieldEditor.
    >>
    >> Mike.
    >>
    >> On 3 Oct 2006, at 02:26, David Aames wrote:
    >>
    >>> Hello all,
    >>>
    >>> I'm writing my own NSCell and I want to be able to edit my cell
    >>> so I would like to learn the proper way of implementing this
    >>> method (editWithFrame:inView:editor:delegate:event:). I cannot
    >>> really understand what this method is supposed to do. I'm
    >>> deliberately not subclassing NSTextFieldCell to use it's
    >>> implementation of this method. So what am I supposed to do in
    >>> this method? I can get the text for this cell and also modify the
    >>> rectangle to match my text but how do I display the editing
    >>> rectangle and everything else? Has anyone actually overridden
    >>> this method without using the super implementation?
    >>>
    >>> Thanks,
    >>> David
    >>> _______________________________________________
    >>> Do not post admin requests to the list. They will be ignored.
    >>> Cocoa-dev mailing list      (<Cocoa-dev...>)
    >>> Help/Unsubscribe/Update your Subscription:
    >>> http://lists.apple.com/mailman/options/cocoa-dev/mike.abdullah%
    >>> 40gmail.com
    >>>
    >>> This email sent to <mike.abdullah...>
    >>
    >
  • I don't know - you've reached the edge of my knowledge on the subject
    I'm afraid!

    Mike.

    On 3 Oct 2006, at 19:20, David Aames wrote:

    > Hello Mike,
    >
    > Firstly I would like to thank you for your help. That's very kind
    > of you. So the algorithm is (as far as I understand):
    > 1. Get a pointer to the field editor (it's passed to me in the
    > function)
    > 2. Make it a subview of the control view
    > 3. Adjust the field editor's frame so it completely covers my drawn
    > text
    > 4. Set the text of the field editor using its setString: method
    >
    > Is that it? Do I have to call some other method to start the
    > editing or not?
    >
    > Thanks very much,
    > David
    >
    > On 3 Oct 2006, at 18:56, Mike Abdullah wrote:
    >
    >> I have to agree with you, Apple's docs aren;t too amazing on this
    >> topic.  I shall (attempt!) to explain:
    >>
    >> Basically, when you edit some text, you use an NSTextView.
    >> However, imagine you have 50 or so NSTextViews in your app, it
    >> will get bogged down quite a bit!
    >>
    >> So instead, we have NSTextField which is more "lightweight."
    >>
    >> Additionally, every window has a Field Editor which is a single
    >> instance of NSTextView.
    >>
    >> When an NSTextFieldCell (or similar class) wants to edit some
    >> text, it gets the field editor from the window and positions it
    >> above itself.  The user types into this NSTextView, and it is this
    >> which provides the focus ring above the control.
    >>
    >> So, in your method, you basically need to get the field editor
    >> from the window and make it a subview of your controlview.
    >>
    >> Mike.
    >>
    >> On 3 Oct 2006, at 17:53, David Aames wrote:
    >>
    >>> Hello Mike,
    >>>
    >>> I did and it included just general information and nothing
    >>> specific on implementing editWithFrame: from scratch.
    >>>
    >>> Thanks
    >>>
    >>> On 3 Oct 2006, at 11:53, Mike Abdullah wrote:
    >>>
    >>>> I think you need to read up on the window's fieldEditor.
    >>>>
    >>>> Mike.
    >>>>
    >>>> On 3 Oct 2006, at 02:26, David Aames wrote:
    >>>>
    >>>>> Hello all,
    >>>>>
    >>>>> I'm writing my own NSCell and I want to be able to edit my cell
    >>>>> so I would like to learn the proper way of implementing this
    >>>>> method (editWithFrame:inView:editor:delegate:event:). I cannot
    >>>>> really understand what this method is supposed to do. I'm
    >>>>> deliberately not subclassing NSTextFieldCell to use it's
    >>>>> implementation of this method. So what am I supposed to do in
    >>>>> this method? I can get the text for this cell and also modify
    >>>>> the rectangle to match my text but how do I display the editing
    >>>>> rectangle and everything else? Has anyone actually overridden
    >>>>> this method without using the super implementation?
    >>>>>
    >>>>> Thanks,
    >>>>> David
    >>>>> _______________________________________________
    >>>>> Do not post admin requests to the list. They will be ignored.
    >>>>> Cocoa-dev mailing list      (<Cocoa-dev...>)
    >>>>> Help/Unsubscribe/Update your Subscription:
    >>>>> http://lists.apple.com/mailman/options/cocoa-dev/mike.abdullah%
    >>>>> 40gmail.com
    >>>>>
    >>>>> This email sent to <mike.abdullah...>
    >>>>
    >>>
    >>
    >
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today