NSProgressIndicator in NSTableCellView - objective-c

I have an NSTableCellView subclass that contains an NSProgressIndicator.
I have it all updating and animating properly, however it remains greyed out. I suspect this is a view loop issue.
Any thoughts?

NSProgressIndicator will only appear blue if it's on the key window.
If your window isn't the key window you can send it that message [myWindow makeKeyWindow]
Window's without title's or resize bars may not respond to that message, so you may need to subclass your window and override
- (BOOL)canBecomeKeyWindow{return YES}.
This was a problem I ran into with the tint color of an nsprogressindicator on a sheet.
The doc's say to never invoke this method directly.. [myTitlelessWindow becomeKeyWindow] but you can use it to confirm the problem before subclassing your window.

Related

Having trouble moving an UITextView in a UIScrollView when it's the first responder

I have a view controller that is basically a form with multiple UITextFields and UITextView, embedded in a UIScrollView. When an UITextField becomes first responder, the scroll view automatically move to the focused field, which is believe is the behaviour explained in the first answer in this topic :
Disable UIScrollView scrolling when UITextField becomes first responder
This does not happen when the first responder is an UITextView though, and I'm not sure why and how I should fix it.
The second problem is that when the keyboard is shown, the scroll view does not scroll if the UITextView is not in view (because it's hidden by the newly shown keyboard). I implemented the code of Apple's documentation on how to manage the keyboard :
http://developer.apple.com/library/ios/#DOCUMENTATION/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html
And added another activeField variable named activeView for textViews (initialized in the beginEditing of TextView, set to nil in endEditing, and scrollToVisible according to it's frame when the keyboard is shown). The problem here is that the beginEditing in UITextView is called after the keyboardWasShown, so the activeView is not initialized and thus does not scroll. For some reason, for UITextFields the beginEditing is called before, which is the intended behaviour.
How can I scroll to an UITextView and it's the first responder, and how can I move to it when the keyboard is shown and hide it?
To scroll to show anything in a UIScrollView do
scrollRectToVisible:/*frame of object you want to show*/ animated:YES
Subscribe to UITextViewTextDidBeginEditingNotification and call the above method when you get it.

NSTextField inside NSPopover is not key until mouse click

I've got an NSPopover that is shown from interaction with an NSStatusItem. I've blogged about the hacks I needed to do to make input even possible in this situation here: http://blog.brokenrobotllc.com/using-nspopover-with-nsstatusitem
I have an NSTextField inside the NSPopover's content view. When I open the NSPopover, the NSTextField appears as if it is key (the cursor blinks). But, when typing, nothing shows up. If I click the mouse in the field, my input starts showing up there.
I've tried things like invoking NSWindow's makeFirstResponder upon popoverDidShow:. There was no change in behavior from this. Anyone have any ideas here?
My guess is you need to make your app active; try calling
[NSApp activateIgnoringOtherApps:YES];
when you show your popover.
Edit: Of course, I could be wrong. This is all just off the top of my head.

UISearchDisplayController not displaying keyboard when text area touched

I have a UITableView in a controller that is nested under a UITabBar.
The interaction is all wired up in Interface Builder so far, nothing done programmatically in terms of view switching.
I've added a UISearchDisplayController as the header of my UITableView. It displays fine, and when I tap on the text entry area, the cancel button appears and the black overlay flies in.
However, the keyboard never appears and when tapping the cancel button, the overlay flies out and the cancel button disappears, but the text entry area keeps focus and the caret stays flashing there, so I cannot tap there again to re-display the search results.
So essentially I have two problems:
Keyboard not appearing when starting to edit text on UISearchBar from UISearchDisplayController
UISearchBar not loosing focus when cancel button is tapped.
What am I doing wrong?
The .xib file that had my tab bar in it contained a UIWindow.
This lead to all sorts of craziness and in the end I gave up on trying to do this with interface builder, and resorted to constructing the UITabBar in code, thereby not creating a second UIWindow.
This resolved the problems and the UISearchDisplayController behaved correctly.
check this method in UISearchBarDelegate:
- (void)searchBarCancelButtonClicked:(UISearchBar *) searchBar;
Try to see if this is getting called and do keyboard-related removal in here. If not, try making another UISearchDisplayController. (I actually never use the default viewController's one). Also, make sure the delegate is correctly set.

NSPanel with "Title Bar" unchecked in Interface Builder does not appear

So I thought I had covered my bases, but apparently I'm missing a key step or two.
I have an NSPanel that is displayed (makeKeyAndOrderFront:) when an NSStatusItem is pressed. Things work great, but as the NSPanel displays a title bar, the panel is also draggable. (This is undesired.)
The first screenshot shows the panel with "Title Bar" enabled in Interface Builder, in the Appearance category. (Sorry for the blur, things are still under lock and key for now.)
The only change that is made in Interface Builder is unchecking the "Title Bar" checkbox. I then save and re-run, and that's what you see in the second screenshot. While a slight shadow appears, the panel does not.
Things I've tried:
I've subclassed the NSPanel and returned YES for canBecomeKeyWindow and canBecomeMainWindow after a bit of research, but (prior to subclassing) these methods both returned NO regardless of whether I was using a Title Bar or not. So I don't think this is the issue.
I've ensured that the frame for the NSPanel is properly set. It has a good height, and the origin is set properly as well.
Edit: Forgot to Mention:
The application is a menu-bar-only application. In the screenshot below, note that an additional entry was added to Info.plist to enforce this.
I've had problems with this in the past. I was able to resolve it by first "ignoring" other apps, then making it the key window. Give it a shot and see if it works for you.
[NSApp activateIgnoringOtherApps:YES];
[[self window]makeKeyAndOrderFront:self];
Also, try setting the window level to NSPopUpMenuWindowLevel during initialization.
[[self window]setLevel:NSPopUpMenuWindowLevel];
I have also had problems with the way that nib files are loaded on Mac OS X. They're loaded "lazily", which means that they won't be initialized until they're needed. This causes a problem when you're wanting to set specifics on the window, but you can't because awakeFromNib doesn't seem to be called, due to lazy nib loading. To fix this, here's what I've done in the past. In your delegate (or wherever you initialize your window), kick the window into action by accessing the window property on the initialized class:
wc = [[blah alloc]initWithWindowNibName:NSStringFromClass([blah class])];
(void)[wc window]; //just kicks the lazy nib loading into gear
By doing so, you're forcing the nib to initialize. That way, when the user clicks the menubar icon the nib is already initialized, and awakeFromNib has already been called.
While a slight shadow appears, the panel does not.
Are you saying makeKeyAndOrderFront: on this NSPanel object doesn't display it when running your app? I just created a sample project, NSButton triggers the same type of NSPanel to display, and it works fine.. titleBar enabled or not.
http://cl.ly/3d0U3C0P3u2D0m3T1w1N

How to keep NSPanel within NSScreen visibleframe always

I have one floating NSPanel in my app, which user can move using mouse. I want my NSPanel to always visible within main screen. I want code to reposition my NSPanel with its original width and height within screen border in all the sides.
Thanks,
Subclass NSPanel and override the frame-relative methods. setFrameOrigin:, setFrame:display: and maybe others (see the documentation to find out all the methods). There is also promising - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen method.