On Jun 6, 2006, Eric Schlegel <email@hidden> wrote
On Jun 6, 2006, at 7:57 AM, Matt Gough wrote:
My app has a Utility window which can show a sheet. This sheet has
an edit text field in it (and an OK and Cancel button).
When my sheet first comes up, I SetKeyboardFocus on the text field.
The user can quite happily type into it. If however, the user
clicks in another application, the text field still appears focused
and the caret still flashes, but all text entry goes into the other
app. Clicking back into the text field does not recover the
situation. Once it is in this mode, the only way to get the text
field to respond again is to close the sheet and reopen it.
Any ideas?
Sounds like you need to call SetUserFocusWindow on the sheet.
Ordinarily the Window Manager will do this automatically; I suspect
it's being tripped up by the sheet opening on a utility window
rather than a regular document window. Please file a bug about that
problem.
You could probably install a kEventControlClick handler on the edit
field in the sheet and call SetUserFocusWindow from that point.
-eric
I have a (perhaps) similar problem with a small "utility" window that
contains a couple of buttons. The window has kEventControlHit and
kEventRawKeyDown event handers. I wanted to have the buttons respond
to the keyboard (they work fine with the mouse). If I simply switch
the window type to Modal or Floating in the nib file, then my Event
Handler works fine. However, I make it a utility window, then another
window in my application gets the keyboard event, even though it is
behind the utility window. Calling SetUserFocusWindow doesn't seem to
help.
I guess I don't really understand the concept of "utility window.