All,
I have an app where user can store a car name and its related features and specs. The car names are shown in a combo box. All the data about a car is stored in a plist file. A handler called textfieldDidEndEditing_ is connected to the combo box. Inside this handler I have a statement that calls a function that resets the form fields. The issue is that currently when user enters a new car name in the combo box , and then fills up other form fields, the information gets reset.The problem is that when user enters a new car name in the combo box, and transfers focus to input controls like checkboxes, drop downs and segment controls, the cursor still remains inside the combobox.
When I shift the focus on a textfield, the cursor moves to it and the textfieldDidEndEditing_ handler gets called, reseting the form fields. Is there a way I can avoid this?
Here is the piece of code:
property aCarName : missing value -- Combobox
-- Other form properties...
on textfieldDidEndEditing_(sender)
try
set tagNumber to sender's tag() as string
if tagNumber is equal to "150" then --combobox tag number
set currentCarSelection to (aCarName's stringValue) as string --get current selection
set doesexist to aCarName's indexOfItemWithObjectValue_(currentCarSelection) -- see if the car exists
if doesexist is not equal to (current application's NSNotFound) then
my CarForm(currentCarSelection) --if the car exists, update the fields in the UI
else
my reset_form(false)
end if
end if
end try
end textfieldDidEndEditing_
on reset_form(clear_combobox)
--clear_combobox is flag that determines if the combobox should be cleared.
if clear_combobox then
aCarName's setObjectValue_("")
end if
--- code to reset all form fields ...
end reset_form