Here is an interesting one… The user types something into a combo box but doesn’t leave the object. Then, they click a button which triggers a script to get interface data and save it somewhere. Problem is, if they don’t’ leave that object, the change of value isn’t registered and other objects lists are not updated.
Is there a way to, upon the user clicking a button, to exit from the field they may still be in.
Does this make sense?
Yes it makes sense:
Is the action ‘send on enter only’?
if the action is ‘send on end editing’ then you can change the first responder when you hit the save button.
It is set to “Sent on End Editing”. When I change it to “Send on Enter Only” nothing happens when the user types or a selection is made from the combo box list. So, I assume I have it set correctly or at least correct for my setup.
Would this change the first responder for the interface from then on or is that just a temporary change to deselect the field? Or… am I completely not understanding?
It’s always wise when you use a window (or panel) that act like a form that you tell the window to set it’s firstResponder to nil. This way all uncommitted objects will commit. When you
--the following code just for illustration and not tested;
script someObject
property parent : class "NSObject"
property theWindow : missing value --IBOutlet
property comboBox : missing value --IBOutlet
property firstTextField : missing value --IBOutlet
on showWindow_(sender)--IBAction
--only set a first responder if the object wants to
if firstTextField's acceptsFirstResponder() then theWindow's makeFirstResponder_(firstTextField)
--now you do the rest like displaying the window....
end showWindow
on saveButton_(sender) --IBAction
--commit all uncommitted objects
theWindow's makeFirstResponder_(missing value)
--now everything is committed we can continue
set x to comboBox's stringValue_()
end saveButton
end script
Very interesting… thanks!!!