Professional Web Applications Themes

Cocoa: how to temporarily disable a popup item ? - Mac Programming

Cocoa: how to temporarily disable a popup item ?...

  1. #1

    Default Cocoa: how to temporarily disable a popup item ?

    Cocoa: how to temporarily disable a popup item ?
    Alain Guest

  2. #2

    Default Re: Cocoa: how to temporarily disable a popup item ?

    dans l'article 168.1.3, Alain Birtz à
    ca a écrit le 18/04/04 0:56:
     

    Menu = [popup menu];
    Item = [menu itemAtIndex:n];
    [Item setEnabled:false];

    Eric

    Eric Guest

  3. #3

    Default Re: Cocoa: how to temporarily disable a popup item ?

    But this work only for index 0.
    So only the title is disabled (pullsDown popup)...

    In article <BCA78ECE.1F032%fr>, Eric VERGNAUD
    <fr> wrote:
     
    >
    > Menu = [popup menu];
    > Item = [menu itemAtIndex:n];
    > [Item setEnabled:false];
    >
    > Eric[/ref]
    Alain Guest

  4. #4

    Default Re: Cocoa: how to temporarily disable a popup item ?

    In article <168.1.3>, Alain Birtz
    <ca> wrote:
     
    > >
    > > Menu = [popup menu];
    > > Item = [menu itemAtIndex:n];
    > > [Item setEnabled:false];[/ref][/ref]

    See the Cocoa doentation on Menus and Popup Lists and the section on
    enabling menu items in there. There a couple of different schemes that
    can be used for how menu items (including popup items) get enabled and
    disabled. Assuming that are using the default automatic enabling
    (which enables menu items if there is an action associated with them),
    you will need to implement

    - (BOOL)validateMenuItem:(id <NSMenuItem>)menuItem

    in the pop-up's target. Note that the easy way to do this is go give
    each of your menu items a tag number in Interface Builder (start with
    some high numbers like 2501 so you don't get a conflict with any of
    your other menu items) and then just do an if in validateMenuItem:

    if ([menuItem tag] == mItemToBeInvalidatedTagNumber)
    return NO;
    .... // test for as menu as you need to
    else // you need this default at the end so
    return YES // everything else gets validated

    You can also check against the name of your menu item but this gets
    really messy if you have localized your program. Tag numbers don't
    care if you are in French or German.

    validateMenuItem: will be the way you MUST do it unless you have
    subclassed your popup menu, implemented:

    - (void)setAutoenablesItems:(BOOL)flag

    and returned NO. In this case (and ONLY in this case) would you use
    the setEnabled: method and then you must enable or disable each and
    every item.

    If you want to turn the entire popup off, then you would call
    setEnabled on the popup itself:

    [popup setEnabled:NO];

    In this case, the popup will show the current selected item as dimmed
    and it won't respond to mouseclicks at all.

    Spence

    --
    James P. Spencer
    Rochester, MN

    "Badges?? We don't need no stinkin badges!"
    James Guest

  5. #5

    Default Re: Cocoa: how to temporarily disable a popup item ?

    In article <180420040907015785%net>,
    James Spencer <net> wrote:
     

    I assign tag numbers based on menu/sub-menu item location. For example,
    if the item is located in the 2nd menu, 3rd position (a sub-menu), 1st
    position within sub-menu, it gets a tag of 231. Another item in the 2nd
    menu proper would get a tag like 22 (2nd menu, 2nd item). Use as many
    digits per field as necessary to guarantee uniqueness; you wouldn't want
    to confuse 1st menu, 11th item (111) with 11th menu, 1st item (111). So
    there you'd use at least two digits per field (which is probably not a
    bad idea generally; if you've got more than 99 menus and/or 99 menu
    items - hoo boy!).

    Yes, it does require a bit of work if you re-organize your menus but in
    your code you are defining and using mnemonics for the item tags, right?

    --
    PGP Key (DH/DSS): http://www.shimkus.com/public_key.asc
    PGP Fingerprint: 89B4 52DA CF10 EE03 02AD 9134 21C6 2A68 CE52 EE1A

    Windows has always aspired to be Mac-like without Microsoft ever really
    understanding what that even means. - Robert Cringely
    Joe Guest

Similar Threads

  1. How to disable autoupdate popup for Player 8?
    By Pete R in forum Macromedia Flash Player
    Replies: 3
    Last Post: March 6th, 07:27 PM
  2. How do I add an item to a controls popup menu in the designer?
    By Don in forum ASP.NET Building Controls
    Replies: 0
    Last Post: July 14th, 09:43 PM
  3. Replies: 2
    Last Post: April 17th, 06:32 PM
  4. how to disable item in combobox
    By neh in forum Macromedia Flash Actionscript
    Replies: 1
    Last Post: February 23rd, 05:08 PM
  5. how to disable flash popup?
    By Krystonia5 in forum Macromedia Flash
    Replies: 1
    Last Post: February 5th, 03:33 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139