Sign In/My Account | View Cart  

advertisement

AddThis Social Bookmark Button

Article:
  Creating Toolbars for Mac OS X
Subject:   A few questions
Date:   2002-03-18 16:49:28
From:   michele
1 - I've searched how to dim the icon when the toolbar item validate method returns no, as it is in Mail for example.


Any idea how to do that?


2 - If I would to have the search item (hence the corresponding textfield) disabled when there is no record, would I subclass NSToolbarItem to override the validate method? Hence changing completely the actual implementation?


Michele


Full Threads Oldest First

Showing messages 1 through 4 of 4.

  • A few questions
    2002-03-22 12:24:33  xyzzy-xyzzy [View]

    I don't understand how to disable the search item either. I've tried changing this function (from the article) to this:

    - (BOOL)validateToolbarItem:(NSToolbarItem *)theItem
    {
    return NO;
    }

    and it disables the add and remove, but not the search item (or the customize button, but that makes sense).

    Is there another function I just don't know about yet?
  • A few questions
    2002-03-20 13:07:05  joaquimlopes [View]

    Michele,

    just override the validateToolbarItem in your NSWindowController and return NO when there is no record. Something like this:

    - (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem
    {
    return [[self document] numberOfRecords] > 0;
    }

    Hope this helps.

    Joaquim Lopes
    • A few questions
      2002-03-20 20:21:33  michele [View]

      Hey Joaquim,

      Problem is my application is not document based.

      Michele
      • A few questions
        2002-03-23 07:54:14  joaquimlopes [View]

        There's no problem. Just replace [[self document] numberOfRecords] with the object that returns the number of records such as [myRecordArray count] or whatever.

        Joaquim Lopes