Before I ask my OSX related question please allow me to describe a feature in MS Windows.
If I create a Windows application in MS Visual Studio where the application contains a simple DataGrid the user can simply click into a cell, edit the contents and use the keyboard up/down arrow keys to move quickly out of the cell to the next one. keying out of the cell triggers the EndEdit event. Using the up/down arrow keys like that a user can quickly move down a column editing values without pressing Enter or using the mouse.
I'm trying to do the same with OSX XCode/Swift. Using the mouse to click into a cell and edit is no problem. But it seems as though I have to click the cell twice to get it selected for editing and then after editing I have to press enter or click another cell. I can't simply use the up/down arrow keys to key out of the cell.
Is that simply the way OSX works? I mean I'm making an OSX application so I want it to behave like a native application but it just seems like a lot of entering and clicking is required if, for example, the user was going to edit a few cells.
Are there any properties I need to set in the ViewBased TableView?
Sorry about the long email - I hope I've explained it though.
Thanks
Ian
After much head scratching I've got something that appears to work exactly as I want.
myTableView is on an NSViewController.
In the NSViewController's viewDidLoad() I've got this:
super.viewDidLoad();
NSEvent.addLocalMonitorForEventsMatchingMask(NSEventMask.KeyDownMask, handler:{
(event: NSEvent) in
self.myTableView.keyDown(event);
switch(event.keyCode)
{
case 36:
return nil;
case 125:
return nil;
case 126:
return nil;
default:
return event;
}
})
I have to confess I'm not 100% sure but my thoughts were that the default behavior of the tableView is for the up/down arrow keys to move the row selection up or down a row but that doesn't happen when a cell is being edited. When the text cell has edit focus the up/down keys simply shift the cursor to the start/end of the cell (ie move the cursor within the cell). Not the behavior I want so I thought if I could swallow (make nil) those events within the cell then the arrow keypress would bubble up to the tableview and it would do the up/down row select - if you see what I mean.
Anyway - no matter where my thoughts were - this does seem to work exactly as I want and when the edit focus arrives on the next cell it gets instant edit focus. Basically working just like it does in programs such as excel and numbers etc.
Related
I am searching for a solution to how I can start an ag-grid table with only cell editors. That means I do not want to click into the row or cell to edit the data.
I have found almost a solution for me with this example in the doc:
Full row editing
This is exactly what I am searching for. I can programmatically start editing immediately. The problem with that example is that onCellValueChanged is only fired after the keyboard click "enter" or click on the next row.
I would need a solution where onCellValueChanged is fired immediately after a cell changed.
I can think of two ideas to accomplish this:
Use "No Click Editing"
This is similar to having all cells contain an input box. It just takes 1 click to focus.
https://www.ag-grid.com/javascript-grid-cell-editing/#no-click-editing
Custom cell renderer
Use a custom cell renderer to have input boxes in each cell. Then, you are always in edit mode. And you can control when the value is saved.
https://www.ag-grid.com/javascript-grid-cell-rendering-components/
I am working on an app that uses voice commands to maneuver through text fields. What I need to do is translate the voice command into a touch event on the keyboard. Specifically I need to access the tab key and the return key. The user will not be using the keyboard in this app. I am having a difficult time finding a way to get this done. I know how to convert the voice commands into something that I can use, but I still need to apply that to the keyboard commands. I have researched this extensively and I get what I think are bits and pieces of what I really need, but nothing is connecting the dots for me.
You don't need the keyboard to navigate text fields. You just need to modify the first responder. There unfortunately isn't an easy way to get the current first responder, but you can search for it.
Once you have the first responder, you can move to the next field like this:
[[field nextResponder] becomeFirstResponder];
If you are trying to do this in a very general way, you should first call canBecomeFirstResponder and handle situations where there there are no available first responders and other corner cases, but this generally isn't needed for very simple interfaces.
If you want to manage "enter" in order to end editing and dismiss the keyboard, you can call endEditing: on the superview.
You can modify text without the keyboard by replacing the text property.
I want to create a 4 character custom password entry like the iPhone lock screen page. It's going to have a custom designed keyboard pinpad, but thats not the question. I have 4 boxes for the entry of the pin, and each box is separated and has its own custom design. I currently have a clear UITextView on top of each box. However, I'm not really sure how to link all these together so that when I enter a number in the first box, it automatically advances to the next box so I can type the next number. After the last number has been entered, it should automatically check to see if the password is correct and if so do some action. What is the best way to do this?
When implementing UITextFieldDelegate you should check on textField:shouldChangeCharactersInRange:replacementString:
and you can move keyboard focus to next UITextField via BecomeFirstResponder documentation
So on last UITextField you will hide keyboard and disable all UITextboxes automatically, but If I were you, I would prefer to provide button to start checking pin (to let user correct pin if mistyped)
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?
I am having very annoying issue. I have one form page with 5 custom cells. Each of them has one text field. On the bottom I have one button. In an onclick button function I am gathering values from each of the 5 described text fields.
My problem is that if my keyboard is up, I will get the values of not all but just visible text fields, the ones I don't see are null.
How to override this?
Thx,
Mladen
Separate data you have from your interface, that is store your textfield values in some other place right after you finish input. And access your data there.
UI elements are not intended to store data, but just to display it and allow input - as you can see in your case if you do not see a particular element you cannot be sure that it actually exists.
This might solve your problem..
1. Register your viewcontroller for KeboardNotifications
2.When keyboard will appear resize the view so that all fields will be visible.
3. When keboard will disappear just resize it back and continue..