Interface Builder 3 and Custom Views

  • Hey friends,
    I have a really severe problem with Interface Builder 3: I add a
    custom view to a window and change its class to a NSButton subclass I
    ceated... Then I want to set the target method for this button by
    control-dragging from this custom view to File's Owner (for example),
    but it does not offer to connect those two. It works flawlessly with a
    standard NSButton, but not with my custom view ... what am I doing
    wrong? I did not have this problem with IB2

    Fabian
    nexUmoja.org
  • Is there a particular reason why you cannot add an NSButton to the
    window and change its subclass?

    Mike.

    On 20 Jan 2008, at 08:33, [nexUmoja] Fabian Jäger wrote:

    > Hey friends,
    > I have a really severe problem with Interface Builder 3: I add a
    > custom view to a window and change its class to a NSButton subclass
    > I ceated... Then I want to set the target method for this button by
    > control-dragging from this custom view to File's Owner (for
    > example), but it does not offer to connect those two. It works
    > flawlessly with a standard NSButton, but not with my custom view ...
    > what am I doing wrong? I did not have this problem with IB2
    >
    > Fabian
    > nexUmoja.org
  • On Jan 20, 2008, at 12:33 AM, [nexUmoja] Fabian Jäger wrote:

    > I have a really severe problem with Interface Builder 3: I add a
    > custom view to a window and change its class to a NSButton subclass
    > I ceated... Then I want to set the target method for this button by
    > control-dragging from this custom view to File's Owner (for
    > example), but it does not offer to connect those two. It works
    > flawlessly with a standard NSButton, but not with my custom view ...
    > what am I doing wrong? I did not have this problem with IB2

    How about instead of starting with a "custom view" you start with a
    NSButton, and then change the class of that NSButton to be your custom
    subclass?

    j o a r
  • As far as I can tell, CustomView is only suitable for subclasses of
    NSView. NSButton is further down the line of inheritance and IB
    doesn't work with it like it does normally ...

    What about, starting with NSButton and specifying the Class value as
    your own subclass?

    Nick

    On 20 Ιαν 2008, at 10:33 ΠΜ, [nexUmoja] Fabian Jäger wrote:

    > Hey friends,
    > I have a really severe problem with Interface Builder 3: I add a
    > custom view to a window and change its class to a NSButton subclass
    > I ceated... Then I want to set the target method for this button by
    > control-dragging from this custom view to File's Owner (for
    > example), but it does not offer to connect those two. It works
    > flawlessly with a standard NSButton, but not with my custom view ...
    > what am I doing wrong? I did not have this problem with IB2
    >
    > Fabian
    > nexUmoja.org

    ____________________________________________________________
    Nick Toumpelis                        email: <nick...>
    BEng (Wales), MSc (Manchester)
    Software Developer
    Thessaloniki, Greece
  • With Interface Builder 2 it worked without any problems to use a
    Custom View and change its class to my NSButton subclass...
    I already tried to change the class of an NSButton in Interface
    Builder 3 to my subclass, but unfortunately it does not change its
    appearance accordingly. It seems not to change the class of the
    button :-(

    Fabian

    Am 20.01.2008 um 10:49 schrieb Nick Toumpelis:

    > As far as I can tell, CustomView is only suitable for subclasses of
    > NSView. NSButton is further down the line of inheritance and IB
    > doesn't work with it like it does normally ...
    >
    > What about, starting with NSButton and specifying the Class value as
    > your own subclass?
    >
    > Nick
  • According to the docs*, the underlying NSCell handles the actual
    drawing of the control. When controls want to draw themselves, they
    send a drawWithFrame:inView: message to their cell.

    Try moving your drawing code to a subclass of NSButtonCell** and
    replace NSButton and NSButtonCell with your custom subclasses***. That
    should work.

    Hope this helps,

    Nick

    * http://developer.apple.com/documentation/Cocoa/Conceptual/ControlCell/Conce
    pts/ControlsAndCells.html

    ** http://developer.apple.com/documentation/Cocoa/Conceptual/ControlCell/Tasks
    /SubclassingNSCell.html

    *** http://developer.apple.com/documentation/Cocoa/Conceptual/ControlCell/Tasks
    /SubclassingNSControl.html


    On 20 Ιαν 2008, at 12:07 ΜΜ, [nexUmoja] Fabian Jäger wrote:

    > With Interface Builder 2 it worked without any problems to use a
    > Custom View and change its class to my NSButton subclass...
    > I already tried to change the class of an NSButton in Interface
    > Builder 3 to my subclass, but unfortunately it does not change its
    > appearance accordingly. It seems not to change the class of the
    > button :-(
    >
    > Fabian
    >
    > Am 20.01.2008 um 10:49 schrieb Nick Toumpelis:
    >
    >> As far as I can tell, CustomView is only suitable for subclasses of
    >> NSView. NSButton is further down the line of inheritance and IB
    >> doesn't work with it like it does normally ...
    >>
    >> What about, starting with NSButton and specifying the Class value
    >> as your own subclass?
    >>
    >> Nick

    ____________________________________________________________
    Nick Toumpelis                        email: <nick...>
    BEng (Wales), MSc (Manchester)
    Software Developer
    Thessaloniki, Greece
  • Hey Fabian -

    The fact that you cannot connect the custom view's action is a bug in
    Interface Builder 3.0. You should be able to apply the connection. The
    good news is that this particular bug is already been fixed.

    When you set the 'custom class' in interface builder, all that is
    happening is that a piece of meta-data is being attached to the object
    that says "At runtime make this an instance of X instead of Y." The
    change only happens at runtime though. So, when you start with a
    custom view in IB, and change it's custom class to "MyView", for all
    of design time, the object is still an instance of "CustomView". It
    only becomes a "MyView" at runtime. The same goes for NSButton's, if
    you change the custom class of an NSButton to a "MyButton", for the
    entire time that the button is in IB, it is a "NSButton", only at
    runtime does it become a "MyButton."

    The benefit of applying the custom class information of "MyButton" to
    an NSButton, instead of a custom view, is that you can still use the
    button inspector in IB to set your button's inherited properties.
    You'll also be able to work around the action connecting bug, and in a
    couple of minutes, you'll probably also realize that you need to set
    the custom class on your button cell too. With an NSButton instead of
    an NSCustomView, this will all be much easier.

    Good Luck -
    Jon Hess

    On Jan 20, 2008, at 2:07 AM, [nexUmoja] Fabian Jäger wrote:

    > With Interface Builder 2 it worked without any problems to use a
    > Custom View and change its class to my NSButton subclass...
    > I already tried to change the class of an NSButton in Interface
    > Builder 3 to my subclass, but unfortunately it does not change its
    > appearance accordingly. It seems not to change the class of the
    > button :-(
    >
    > Fabian
    >
    > Am 20.01.2008 um 10:49 schrieb Nick Toumpelis:
    >
    >> As far as I can tell, CustomView is only suitable for subclasses of
    >> NSView. NSButton is further down the line of inheritance and IB
    >> doesn't work with it like it does normally ...
    >>
    >> What about, starting with NSButton and specifying the Class value
    >> as your own subclass?
    >>
    >> Nick

previous month january 2008 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