Keep window in focus always in swift Cocoa [duplicate] - swift

I have noticed in the Interface Builder if I want to click on or drag from the Library panel, I only have to click on it once, even if the Library panel does not have the current focus.
I am trying to build a panel that behaves similarly.
Is there any simple way to let the NSTableView accept the click, even if the window does not have the focus?
Thanks.

Ok, I found the answer. Inside from awakeFromNib I call this:
[self setBecomesKeyOnlyIfNeeded:YES];
It seems to do the trick. It's a little bit different from Interface Builder where the Panel actually gets the focus simultaneously with a single click, but doing it this way is just what I was looking for.

Your view should override -acceptsFirstMouse: to return YES (or evaluate the event passed to you to determine what to return). You'll have to subclass NSTableView to do that of course.

Related

How to make a SAPUI5 Custom Control accessible (focus handling)?

I am searching for a way to make a SAPUI5 custom control accessible. I build a kind of tile (based on a VBox control) and try to get this custom control accessible over keyboard (tab) or by clicking the mouse.
My idea was to implement sap.ui.core.Control#getAccessibilityInfo in my control, but this seems never be called. Currently I am trying to debug how other stuff is doing it like https://github.com/SAP/openui5/blob/master/src/sap.m/src/sap/m/ListBase.js but I can't find a way that works.
My control is currently placed inside a table, if I click on it the focus will be set to the table column. If I press tab-key it jumps to an input control inside my control.
My assumption, I miss something so that the control would be considered as focusable somehow.
I think that you are looking for ItemNavigation. VBox wasn't design to support keyboard navigation on it's content, but you could add a hook to onAfterRendering of your custom control, collect all dom refs you need to navigate on and pass them to ItemNavigation.setItemDomRefs.
If you need an inspiration you can have a look at sap.m.List implementation.
The important thing is to add oRM.writeAttribute("tabindex", "0"); // allows selection into the renderer of my own control. That allows to use the tab handling. Full code in a different question: How to copy&paste SAPUI5 controls by pressing Ctrl+C and Ctrl.V?
With this the control can be selected.
Also notice the this._bExcludeFromTabChain = false; in init section.

XCode 10 adding action to button

I'm trying to make a Cocoa app with buttons that run simple command line scripts.
I can't seem to figure out how to add the action to my button.
I've read some docs that suggest holding down option and dragging the button into controller code but I think they are out of date. Can someone suggest how to get there from this screenshot?
You need to first select your button, then hold the control ⌃ button on your keyboard and then drag that across to your view controller. That will then give you the option of what to name your method etc.
Actually I had the same problem and the root cause was just the drag method. From the descriptions I had assumed that I need to press CTL and then drag while having the left mouse button pressed. This did not work at all (in my environment). Then I noticed that "it works" with the right mouse button. But the result was not correct. (E.g. I could not get "Action"). Finally I found: I have to use the right mouse button only for dragging without holding CTL. Then I got the correct result.

xcode interface builder objects

I want to create a form for an iphone app. I'm using interface builder to create the fields. I need the equivalent of a select drop down menu. The documentation says to use a pop-up button, but I can't find the darn thing. Where the heck is it??
Also, what about checkboxes?
Thanks
For a drop-down menu use UIPickerView named just "Picker View" in IB. Another option although much harder to implement is a collapsible UITableView.
There are no checkboxes provided by default, so usually it is just an image, that changes when you click it. Or you can use a UISwitch named just "Switch" in IB

How to make a combobox in iphone

I am trying to make a combobox in ios following this link http://www.codeproject.com/KB/iPhone/iphonecombobox.aspx.
But the click event (that shows the picker) seems to work sometimes and sometimes not. It looks like sometimes it just works in some regions of the control and not others.
Any idea of what is wrong?
It's kind of hacky, but you can add a hidden UIControl around the region of the ComboBox and then wire it up to the same IBAction or void that the existing ComboBox uses. For example, -(IBAction) showPicker could be the action of a new UIControl that you add right around the region.
For some reason, the answer was using the textfield and image directly to the page instead of creating a view for the control and using that view N times.
I created a combobox api for iOS, hope this could be of any help: http://www.chupamobile.com/products/details/365/ZComboBox/

Why isn't my keyboard appearing?

I have an application that allows the user to edit multiple text fields and views. Rather than mess around raising each view to the top when the keyboard is active, I decided to instead make one textView for editing and hide/show it when input is needed, then transfer the data when it is done. To move focus to the new textView, I call its becomeFirstResponder method, and lo and behold, the cursor goes to the right place. However if I use this method, the iPhone keyboard does not appear. I have no idea why. Can anyone explain, and tell me how to make the keyboard appear? All the other questions I've looked at seem to indicate that setting becomeFirstResponder for a textView ought to make the keyboard come up.
-Ash
Is Hardware -> Simulate Hardware Keyboard enabled?
Are you doing this whole thing programatically or using Interface Builder as well?
If so are the IB connections setup right?