Check UINavigationBar back button visiblity - xcode

How would I check if my UINavigation's bar Back button is visible?
If it is not visible I would like to replace it with alternative functionality.

Related

How make button in NSWindow clickable while a sheet's on top of it

I have created a custom (themed) NSWindow, by creating a borderless window and then recreating all elements of the window border/background inside the content view. I've created the window widgets (close box, zoom box, minimize box) on top of my own fake title bar using -standardWindowButton:forStyleMask:.
Trouble is, when a sheet is presented on top of my custom window (e.g. "save changes...", those buttons do not receive the clicks.
Does anybody know how I can tell NSWindow not to intercept the clicks in my minimize box? It works with a standard NSWindow. When a sheet is up, I can still send both of them to the dock, or zoom the window out.
I thought maybe there's special code in the content view that ignores clicks in subviews while a sheet is up. But it seems as if -hitTest: is called on the content view and returns the minimize widget, but the widget's action never gets triggered.
I guess I could just replace the content view and perform the action in the content view's hitTest if it is the minimize widget ... but that seems a bit ugly.

NSProgressIndicator in NSButton

I have a refresh button in an NSToolbarItem and would like to replace the refresh icon with an NSProgressIndicator when there is data loading. Is this possible? Notably, it should still be a button (or at least look like one) but have the progress indicator instead of the button.
I advice you to put progressIndicator in the same place with your button, but with Hidden flag. after you press the button, hide it and show the progress indicator.
for better effect you can use [[button animator] setHidden:YES] but don't forget to make your views layer backed, to make animator works.

NSWindow's title as indicator popup button

I'm trying to make my first Cocoa app (previously I was making iOS apps) and what I wish to do for my custom view is make it's title clickable with indicator (accessory) triangle facing down.
Clicking the title would open a popup/menu with my items.
How is that doneable in Cocoa?
Rdelmar's answer is probably the easiest way to go, but may not do exactly what you might want to do (which is replace the actual title with a pop up item, instead of having a popup button under the title in the toolbar area). With respect to functionality your application will probably work just as well using the toolbar.
If, however, you truly want to replace the actual title, the means of going about this would be to set the NSWindow title text to #"" to hide it, and redraw it by sticking in your own view.
[[[theWindow contentView] superview] addSubview:theSubview];
This basically tells the superview of the main content view to add another subview (direct "translation" from the code), and you'll have to tinker with the frame of this new subview to have it be positioned where the title should be positioned (as now it's free to be placed anywhere in the window frame, including on top of the title bar, as opposed to simply inside the content view).
theSubview can be your popup button, or whatever you want, and you'll also probably have to custom draw the popup button to match the original drawing of the window title.
You can do this by adding a toolbar to your window in IB. Once, you add the toolbar, you can double click on it to open the customizer view of it. Drag a popup button into the Allowable Toolbar Items area and after it is inserted there you can drag it into the bottom area which shows the layout of the toolbar -- you can also drag out any of the default items there that you don't want.

How to embed an NSMenu inside a borderless window to create a fake menu bar

I am trying to create a fake menu bar in a cocoa application. I have been able to acomplish 95% of what I need, only the menu bar does not match mainMenu. See screen grab below of what I have so far.
I am using a "Pop Up Button" object in a xib to try to emulate the system menu bar. The problem is that it is a popup menu and does not look exactly like the mainMenu. Additionally, the title menu item does not hilite, and the popup menu has rounded corners that overlap the menu title. So, it's close, but no cigar.
Is it possible to create a fake menu bar inside a borderless window that matches the default system menu bar? If so, how?
I also tried using an NSStatusItem, which by default matches the system menu bar more closely than what I have been able to accomplish with a button, but I was unable to embed NSStatusItem into a window.
Ideally, if there is a way to embed an NSMenu directly in a windows view, that would be the best solution.
You'll need to create a custom button or view that looks and acts like the top-level item, then assign an NSMenu to your view's menu outlet.
You can then either implement menuForEvent: in your view and return your menu when the mouse is down, or alternatively call the NSMenu class method +popUpContextMenu:withEvent:forView: when the mouse is clicked.
This seems to be a slightly odd idea, by the way. Why do you want to do it?

How do I keep focus on TextBox after a button was pushed?

I have a XAML ListBox, a TextBox inside the ItemTemplate. A user edits text inside the TextBox, and then presses a button in the application bar. How do I keep the focus on the TextBox after the button in the application bar was pushed?
You don't. You set it back afterwards.
You can use Focus() method to do this.
You can also use the SelectionStart and SelectionLength to highlight a specific part of the text.

Resources