views:

103

answers:

0

Hi,

I am trying to create a number dialing text field, that is, a text field that works in conjunction with an NSStepper sitting next to it.

The text field should display floats and allow the user to use the scroll wheel to adjust the number it is displaying as well as the up and down arrow keys to the same effect.

It should also switch to different increments depending on what modifier keys are pressed. Later on I might implement a behaviour where when the user drags the mouse over the text field left or right while pressing alt it will determine where (at what digit of the number) the insertion caret was placed and only increment that number so that the user can quickly update the ones, tens, hundreds, etc. parts.

While the modifier keys and mouse dragging details are rather just that, details, my question is more concerned with the fundamentals of achieving this in a most unobtrusive manner, so that bindings and other features still continue to work.

So far I got a subclass of NSTextField (with a number formatter attached to its cell in IB) and a subclass of NSTextView for being the number dialing text field's field editor. This is so that I can override keyDown: to make the arrow keys updates happening.

The problem is that returning this field editor for the number dialing text field from windowWillReturnFieldEditor:toObject: of the window's delegate seems to break bindings and generally feels like I shouldn't be doing this.

Am I going about this the wrong way?

PS.: You can find just the subclass code at http://gist.github.com/361265 I wasn't sure if I should post it all here.