Mirroring 2 text fields?

I have 2 text fields in one window that I would like to completely mimic each other. Whatever you do in one, happens in the other. If the cursor is blinking in one, I want it to blink in the other. How would I do this? I’m guessing a little obj C (which of course, I don’t know). :slight_smile: Thanks so much.

-Evan

Here’s an applescript method of making both stay in sync with one another…

on changed theObject
	set theObjectName to (name of theObject) as string
	if (theObjectName is "TextOne") or (theObjectName is "TextTwo") then
		set theObjectString to ((content of theObject) as string)
		if (theObjectName is "TextOne") then set content of text field "TextTwo" of (window of theObject) to theObjectString
		if (theObjectName is "TextTwo") then set content of text field "TextOne" of (window of theObject) to theObjectString
	end if
end changed

There are certainly other methods, including bindings and equivalent cocoa methods, but this is a simple enough task for applescript to handle. You will not be able to easily get the cursor to flash in both fields, though. A window can have only one first responder, and the insertion point cursor is handled automatically by the window depending on which field is first responder. The best you can do without doing some pretty involved window subclassing is capture the events from one field and send them to the other.

j

Thanks. That will work fine for my needs. It’s actually nicer looking if the cursor doesn’t blink in the other field, so, perfect!! I’ll give a try on Monday. :slight_smile: I’ve learned a new handler. YEAH.

-Evan