Select the first item of a NSPopUpButtonCell's new menu

This commit is contained in:
Wolfgang Lux 2022-02-26 15:30:26 +01:00
parent ec3353ecd8
commit efb9bcb2e7
2 changed files with 7 additions and 2 deletions

View file

@ -1,5 +1,9 @@
2022-02-26 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSPopUpButtonCell.m(setMenu:): Select the first item of
the menu instead of the last, as this is the only selection that
makes sense for pull downs.
* Source/NSPopUpButtonCell.m: Never change the state of the
selected item when configured as a pull down to match Apple's
documentation and implementation.

View file

@ -210,8 +210,9 @@ static NSImage *_pbc_image[5];
[self setMenuView: nil];
}
// FIXME: Select the first or last item?
[self selectItemAtIndex: [_menu numberOfItems] - 1];
// Select the first item because that is the only selection that makes
// sense for pull downs.
[self selectItemAtIndex: [_menu numberOfItems] > 0 ? 0 : - 1];
[self synchronizeTitleAndSelectedItem];
}