I am working on some general dialogs for our content management system. Everything is written programmatically in Cocoa/Objective-C without using xib files.
Unfortunately the focus ring is never displayed, even though I can use TAB to move between the controls, and even though all controls are (or are inherited from) standard controls like NSButton, NSTextField and NSTextView.
On the other side, if I use xib files or storyboard files to make similar dialogs, the focus ring is shown without problems.
I expected that you only would need to draw the focus ring yourself if you are creating a custom view, which is directly inherited from NSView itself, regardless if you are using xib files or not.
Can anyone please help with this? Thank you very much in advance!
Related
I have a control in one of my storyboard that I copy in a lot of screen and even projects. It's just native controls with stack view, scroll views, labels, etc placed with auto-layout already wired together.
Is there a way to add this into the Object Library in Xcode so I can just drag it from there onto my storyboard and still see all the native controls? I want to be able to drag and drop other controls into the stack view and even modify it from there within IB.
I do not want to do this programatically because I want to continue using Interface Builder for my custom control.
s there a way to add this into the Object Library in Xcode so I can just drag it from there onto my storyboard and still see all the native controls?
No. The usual strategy is to keep it in a xib file (so you are using Interface Builder to construct the view complex) and load the nib programatically to get at the view and put it in the interface at runtime. To some extent you can automate that programmatic process by means of a view subclass that loads its own content from the nib.
Or, if this view has different manifestations in different contexts, you might just have to use copy and paste of some template version (presumably you’re already doing that).
I'm looking for a way to customize the drag/drop of windows/tabs. I have a document based app, with a custom window controller. I am able to create tabs for it and have them all along the top, they all show, everything works great with that.
Where I'm running into trouble is if I create a different unconnected windows and start trying to drag windows or tabs into different windows or tab bars to have it dock or merge. Sometimes it works how I want, sometimes it doesn't allow docking or anything. Other times it does what I don't want it to do. I need a way to help it along...
I'm looking for a way to tie into those events but in all my searching I can't find what api or where it is that is controlling the window drags/drops. I looked into the NSDraggingDestination but that has nothing relating to windows, just pasteboard stuff. Looked at NSWindowController and didn't see anything there either. Anyone know if this is possible?
I have a problem with accessory views on NSSavePanel and NSOpenPanel.
Sometimes, (very often) when I open one of these panels the accessory view does not work (the view is shown but controls seem disabled).
I'm using this code to show the panel:
[openPanel beginSheetModalForWindow:appWindow completionHandler:openPanelHandler];
This only happens when app-sandbox is enabled.
After much testing I found out that what was happening was that the view was being misplaced (not attached to the panel).
When I open Mission Control and move the mouse pointer over the app windows I noticed that an "invisible" window hilighted and when select it I can take control over the accessory view (all controls work) but it appears detached from the open or save panel as shown on the screenshot.
I tried to create a new app just to test this behavior but was not able to reproduce it, so I suppose that has something to do with my app.
Any hint of what I may be doing wrong?
I don't want to code everything from scratch just to solve this issue.
Edit
Just a side note, when I close the window, just before the window close the accessory view flashes with the correct values for the controls. It appears that the application does not add the view in time for showing the panel.
Update 1
I subclassed the view that is used as accessory view and noticed that the
- (void)viewWillMoveToSuperview:(NSView *)newSuperview
is called, but
- (void)viewDidMoveToSuperview
never gets called even when the view is shown correctly, is this the normal behavior?
Update 2
I confirmed that - (void)viewDidMoveToSuperview should be called, on the test app both methods are called.
I also noticed a slight difference between my app and the test app. On my app the panel just slides down but on the test app the panel appears to "flip down" (don't know exactly how describe). The way the panel appears is irrelevant to me, I just noticed that it is not shown the same way.
After trying many things I concluded that the problem had to do with ARC (Automatic Reference Count) settings for the project.
In my case I had enabled ARC on target but not on project, after enabling ARC on project (and dealing with resulting errors and warnings) everything works perfectly now.
I was wondering if anyone else has seen this. I would include a screen shot but it would be unilluminating, showing all the referencing outlets and event handlers hooked up exactly as they should be, the same thing that was working perfectly before I made some changes. I had a very simple UIView with some text and a single control which I edited to have more controls, and after building none of them worked. The IBOutlet variables all worked, I was able to set text and control states on viewWillLoad, but all control were inactive. They were enabled, allowing user interaction, I even tried setting their enabled properties in code. Dead.
Finally I created a new view, copied and pasted the subviews into it, hooked up the event handlers and referencing outlets, and it worked right away.
Does anyone have any insights to share on this? I tried cleaning the project, rebooting the machine, the whole gamut. OK, "the nib must have been corrupt," but why?
Thanks for any insights.
I have two NSTextFields in a xib file I'm using to display some preferences to users.
There is a save button that I wanted to be unusable until these preferences have been filled out. For some reason, this made all the NSTextFields in the xib file totally unusable as well (it was as if they had been disabled).
When I enable the NSButton, everything works--but with a catch. Whenever I focus the cursor or type in one of the NSTextFields, the text inside flickers. It's really disconcerting.
There's no custom code powering the UI elements.
Any help is greatly appreciated.
It appears as though this is a bug in Interface Builder.
After deleting the NSTextFields that were flickering and adding them back in IB, the flickering stopped.