views:

13

answers:

1

I just noticed a problem when my user-interface is in a certain state. I have a table view with two columns both of which the user can enter data that is to be used later. There's also a button which acts upon the contents of the table view.

The problem is if the user has entered new data in the column but has not yet exited the field by using the tab key or return key (i.e. the cursor is still in the field and in editing mode) and the button is pressed the old value is used not the current value sitting in the field.

What is the best way to handle this this? I want to use whatever the user has entered thus far.

Basically, The button code needs to tell the text field to finish completion or exit the editing mode. But I can't seem to find a method that will do that.

A: 

Found the answer, At least for me.

Find out if a row is selected and if so the selected. This causes the current entry to be completed.

- (void) completeTableEntry 
{
    // If a column is selected ensure it is completed
    NSInteger sr = [keyValueTable selectedRow];
    if (sr != -1) {
        [keyValueTable deselectRow:sr];
    }
}
tgunr