Select next NSTextField with Tab key in Swift
You have to connect your textField nextKeyView to the next textField through the IB or programmatically:
textField1.nextKeyView = textField2
Select next row when Enter is pressed while editing a NSTextField inside a NSTableView
I would use the NSControlTextEditingDelegate method
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command
with the text field to detect the enter key and
- (void)editColumn:(NSInteger)columnIndex row:(NSInteger)rowIndex withEvent:(NSEvent *)theEvent select:(BOOL)flag
to select the next row in the table view.
TAB in custom NSTextField does not put focus on another control
Seems like it was my fault.
I was incorporating delegate calls within the custom class for textDidBeginEditing:
and textDidEndEditing:
, in order to maintain the placeholder text when the user tabs out of the field, but I wasn't calling the respective super class' methods as well.
After including the call to [super textDidEndEditing...]
and [super textDidBeginEditing...]
tabbing works fine.
How do I manually set the key-view in a cocoa app?
From the documentation of func selectKeyView(following view: NSView)
:
Sends the
nextValidKeyView
message toview
and, if that message returns anNSView
object, invokesmakeFirstResponder(_:)
with the returned object.
To select targetView
, skip nextValidKeyView
and call makeFirstResponder(_:)
.
self.window?.makeFirstResponder(targetView)
Related Topics
Disable Audio (And Interruption) with Mpmovieplayercontroller Using Swift
How to Create Type Erasing Weak References with Non-Optional Properties in Swift
How to Rounded the Corners When I Draw Rectangle Using Uibezierpath Points
iOS Screen Sharing (Using Replaykit) Using Webrtc in Swift
How to Convert a Float Value to Byte Array in Swift
How to Pass an Error Pointer in the Swift Language
Compiler Error: Invalid Library File - Corelocation
Differencein Approach to Create Dispatchqueue Swift3
Uitableviewcell Height Auto Layout Not Working on iOS 10
How to Convert Copaquepointer in Swift to Some Type (Cgcontext? in Particular)
Swift, Pass Data Back from Popover to View Controller
Check for Launching from Uilocalnotification in Swift
Add Text Label and Button to Dynamic Tableview Cell Programmatically with Swift
Is Swift Inout Parameter a Variable or a Pointer
Xcode: Could Not Load Modelio.Framework, Scenekit.Framework, etc
Xcode 8 Swift Update with Error "Use Legacy Swift Language Version"