Note that there are some explanatory texts on larger screens.

plurals
  1. PONo scrolling or user interaction in new NSWindow with NSScrollView
    primarykey
    data
    text
    <p>I am building an application (without interface builder!) which 'lives' in the NSStatusBar; when you click on an icon in the StatusBar a NSWindow with a NSScrollView appears. The window appears but it seems that something is preventing user interaction with the ScrollView</p> <p>To find out where the problem comes from I also added my view to the main windows contentView in the AppDelegate, strange thing is that the scrollview is interactive in the MainWindow... Anyone knows why it doesn't work in my new Window?</p> <p>This is the code I use to create the new TTDropDownWindow:</p> <pre class="lang-c prettyprint-override"><code>- (void)openWindow { // Dropdown if (self.dropDownWindow == nil) { self.dropDownWindow = [[TTDropDownWindow alloc] init]; self.dropDownWindow.releasedWhenClosed = NO; self.dropDownWindow.contentView = self.view; self.dropDownWindow.backgroundColor = [NSColor clearColor]; self.dropDownWindow.delegate = self; self.dropDownWindow.alphaValue = 1; self.dropDownWindow.hasShadow = NO; self.dropDownWindow.opaque = NO; } [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; NSRect statusBarContentRect = self.statusBarItemView.window.frame; NSPoint statusBarOriginPoint = NSMakePoint(NSMidX(statusBarContentRect), NSMinY(statusBarContentRect)); NSRect screenFrame = self.dropDownWindow.screen.frame; NSRect dropDownContentRect = NSZeroRect; dropDownContentRect.size.width = DROP_DOWN_WIDTH; dropDownContentRect.size.height = DROP_DOWN_HEIGHT; dropDownContentRect.origin.x = statusBarOriginPoint.x - DROP_DOWN_WIDTH / 2; dropDownContentRect.origin.y = screenFrame.size.height - DROP_DOWN_HEIGHT - NSStatusBar.systemStatusBar.thickness; [self.dropDownWindow setFrame:dropDownContentRect display:YES]; [self.dropDownWindow makeKeyAndOrderFront:nil]; } </code></pre> <p>This is the implementation of TTDropDownWindow:</p> <pre class="lang-c prettyprint-override"><code>#import "TTDropDownWindow.h" #import "WFConstants.h" @implementation TTDropDownWindow - (id) init { self = [super initWithContentRect:NSMakeRect(0, 0, DROP_DOWN_WIDTH, DROP_DOWN_HEIGHT) styleMask:NSBorderlessWindowMask backing:NSBackingStoreRetained defer:NO]; return self; } - (BOOL)canBecomeMainWindow { return YES; } - (BOOL)canBecomeKeyWindow { return YES; } @end </code></pre> <p>And this is the code that creates the View and the ScrollView</p> <pre class="lang-c prettyprint-override"><code>#import "TTStatusBarDropDownView.h" #import "TTTestView.h" @implementation TTStatusBarDropDownView @synthesize dropDownTableViewData = dropDownTableViewData_; - (id)initWithFrame:(NSRect)frameRect { self = [super initWithFrame:frameRect]; if (self) { NSImageView *imageView = [[NSImageView alloc] initWithFrame:frameRect]; imageView.image = [NSImage imageNamed:@"background-dropdown"]; [self addSubview:imageView]; // first create a view to put in a ScrollView NSView *scrollViewHolder = [[TTTestView alloc] initWithFrame:NSMakeRect(19, 98, 414, 543) andColor:[NSColor yellowColor]]; [self addSubview:scrollViewHolder]; // create the scrollView NSScrollView *scrollView = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 414, 543)]; scrollView.hasVerticalRuler = YES; scrollView.hasVerticalScroller = YES; [scrollViewHolder addSubview:scrollView]; // TTTestView is just a NSView with a background drawing TTTestView *theViewThatScrolls = [[TTTestView alloc] initWithFrame:NSMakeRect(0, 0, 200, 10000) andColor:[NSColor blueColor]]; [theViewThatScrolls addSubview:[[TTTestView alloc] initWithFrame:NSMakeRect(10, 10, 100, 8000) andColor:[NSColor grayColor]]]; [scrollView setDocumentView:theViewThatScrolls]; } return self; } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload