Though Cappuccino has treated me very well so far, text support in Cappuccino is still an area that needs much improvement. Many newcomers still ask about multiline text support, and so far, the solution has been the minimal implementation of CPTextView located here. I've been using this for a while, but recently ran into a few problems, and decided to make it just a little less hacked together =).
First, the code: http://gist.github.com/239696
This code is a bit of an amalgam of code from CPTextField and the old CPTextView. I've tried to make it a bit more cross-browser compatible and have added support for tabbing. I've also changed the behavior to be based roughly on the behavior Ross Boucher implemented for CPTextField as described here. I implement the same delegate methods, except that for CPTextView, the action fires on escape instead of return. Note that this is not actually the behavior of CPTextView in Cocoa, so if you want to override this behavior, I've made sure to let CPTextView be easily overridable. There are no file-scoped functions - you can just override the private methods _keyUpFunction, _keyDownFunction, _keyPressFunction and _blurFunction.
There's still obviously a lot lacking in the code. For one, I didn't really adhere strictly to the Cocoa API for CPTextView when writing this. Additionally, autoscrolling doesn't work, entering text is fairly slow after scrollbars appear, and I would like to implement mouse tracking so that clicking on the CPTextView's scroll bar doesn't fire the blur method for the CPTextView. But this is doing the job for now on Mockingbird.
0 Comments