NSTextField suppressing multi line input

  • Hi All,

    I have a normal NSTextField which i need to ensure has no line breaks
    in it. It works well since there is a default button that traps the
    enter and return keys. but if i go into TextEdit and type two lines

    line 1
    line 2

    and copy both lines, and return to my app and paste the clip board
    into the NSTextField, both lines are entered. you need to up arrow to
    see the line 1 but it is there.

    question: how do you stop the multi line input? NSTextFieldCell has a
    set clip mode method but that is more about how the clipped text is
    drawn. I need to stop it entering in the first place.

    cheers,
    omega
  • On 30 Nov 2007, at 10:05 PM, Warwick Hall wrote:

    > I have a normal NSTextField which i need to ensure has no line
    > breaks in it. It works well since there is a default button that
    > traps the enter and return keys. but if i go into TextEdit and type
    > two lines
    >
    > line 1
    > line 2
    >
    > and copy both lines, and return to my app and paste the clip board
    > into the NSTextField, both lines are entered. you need to up arrow
    > to see the line 1 but it is there.
    >
    > question: how do you stop the multi line input? NSTextFieldCell has
    > a set clip mode method but that is more about how the clipped text
    > is drawn. I need to stop it entering in the first place.

    Does writing a custom NSFormatter help? See especially the
    isPartialStringValid:... methods, though they talk about _typing_
    input; possibly they wouldn't catch pasted text. I'm sorry I don't
    have time to verify this.

    — F
previous month december 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
31            
Go to today