0

I have two problems about objective c cocoa NSComboBox.

  1. How can I set the scroll bar always visible, not just scroll the list.

  2. Can I open the list by clicked the text, not just clicking the arrows.

HipSze
  • 19
  • 4

1 Answers1

0
  1. When the pop window open , you can find the scrollview inside the popup window and change the visible property of that .Please refer this code : https://github.com/ilg/IGResizableComboBox steps :

a) Find the combo box window

- (NSWindow *)comboBoxPopUpWindow
{
    NSWindow *child = nil;
    for (child in [[self window] childWindows]) {

            if ([[child className] isEqualToString:@"NSComboBoxWindow"]) {
                break;
            }

        }

    return child;
}

b) iterate the subviews of the windows content view

-(NSScrollView*)findScrollView:(NSWindow*)window
{
    NSView *contentView = [window contentView];
    for(NSView *view in [contentView subViews]){
     if([[view className] isEqualToString:@"NSScrollView"]){
       return scrollView;
      }
   }

}

c) Modify scrollview property

  1. You can override the mouse down and open the list. For opening the list, please refer this : How to programmatically open an NSComboBox's list?
Community
  • 1
  • 1
Sheen Vempeny
  • 818
  • 1
  • 5
  • 8
  • override the mouse down and open the list is work. I added the NSButton and call the function you provided. But i don't know how to set the scrollview. i want the scroll bar show for long time when the combobox list opened. – HipSze Apr 16 '15 at 08:21
  • @HipSize , Modified the answer – Sheen Vempeny Apr 16 '15 at 08:54