Core Data Binded Text Fields

  • I have numerous text fields laid out in a form. Before I made Core
    Data bindings to them, the first NSTextField was focused when the
    window opened and Tab correctly went to each field. After I bound the
    fields to the Core Data object, however, when the window opens, the
    focused text field is the very last one (which is not bound to Core
    Data).

    So I set the window's initialFirstResponder to the first NSTextField,
    but no luck. I manually setup all the nextKeyView connections and now
    tabbing works correctly, but the window still opens with the very last
    text field focused instead of the first.

    I'd manually set that field to be focused when the window appears, but
    I can't find the code to set focus on a NSTextField.

    Thanks in advance,
    Jason
  • Am 15.11.2007 um 13:39 schrieb Jason Ketterman:
    > I'd manually set that field to be focused when the window appears,
    > but I can't find the code to set focus on a NSTextField.

    makeFirstResponder, or makeKeyView, or something like that...

    Cheers,
    -- M. Uli Kusterer
    "The Witnesses of TeachText are everywhere..."
    http://www.zathras.de
  • I'm new to debugging, I think I set this up correctly, but may have
    failed. Here is the backtrace without any calls to makeFirstResponder
    and without the Window's initialFirstResponder set. (This
    configuration correctly focuses on the first NSTextField unless it has
    a binding.)

    http://nflux.net/lcb/backtrace.png

    I'm not sure what NSWindow uses to select the first key view, but it
    won't pick any controls with Core Data bindings attached to them. If I
    set the Window's initialFirstResponder, makeFirstResponder does not
    get called when the window loads, and it still does not focus on the
    field I selected as the initialFirstResponder.

    I'm thinking this is an AppKit bug, and I'm going to file a bug report
    unless someone can just tell me how stupid I am.

    Thanks,
    Jason

    On Nov 15, 2007, at 10:04 AM, Uli Kusterer wrote:

    > Am 15.11.2007 um 15:48 schrieb Jason Ketterman:
    >> For some reason, that doesn't end up working. The only way I can
    >> get the first text field to be the first responder is to do a
    >> performSelector... afterDelay. I know that has to be some horrible
    >> work-around. I'm calling the code from inside of windowDidLoad, I
    >> don't know if that makes a difference.
    >
    >
    > That probably means that someone else is changing the focus after
    > windowDidLoad. So, your setting succeeds, but is undone by whoever
    > else does that. Do you have any other code (accessors?) that changes
    > the keyboard focus? Have you tried setting a breakpoint in the
    > debugger on [NSView makeFirstResponder] or whatever that logs a
    > backtrace and then continues? That might tell you who, apart from
    > you, is calling this.
    >
    > Cheers,
    > -- M. Uli Kusterer
    > "The Witnesses of TeachText are everywhere..."
    > http://www.zathras.de
    >
    >
    >
    >
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today