Updated & New Code

May 25, 2007 at 2:15 PM

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/darkshadow/nightproductions.net/blog/wp-includes/formatting.php on line 74

For all of you developers who are using my code (all 3 of you), I’ve updated my DSClickableURLTextField and DSGeneralOutlineView classes, and added a new class, DSGeneralTableView. I’ve also written up some class references for these classes, so things are a little more documented now.

Jens Miltner emailed me some fixes to some subtle bugs with DSClickableURLTextField, and I added some functionality. Here’s the change list for it:

    Changes by Jens Miltner:

  • Fixed a problem with the text storage and the text field’s attributed string value having different lengths, causing range exceptions.
  • Added a delegate method allowing custom handling of URLs.
  • Tracks initially clicked URL at -mouseDown: to avoid situations where dragging would end up in a different URL at -mouseUp:, opening that URL. This includes situations where the user clicks on an empty area of the text field, drags the mouse, and ends up on top of a link, which would then erroneously open that link.
  • Fixed to allow string links to work as well as URL links.
    Changes by me:

  • Overrode -initWithCoder:, -initWithFrame:, and -awakeFromNib to explicitly set the text field to non-editable and non-selectable. Now you don’t need to remember to set this up, and the class will work correctly regardless.
  • Added in the ability for the user to copy URLs to the clipboard. Note that this is off by default.
  • Some code clean up.

I cleaned up the code a bit in DSGeneralOutlineView, and also added a new delegate method. Also of note, I added a parameter to the delegate method allowing you to create a custom drag image. If anyone is using this with DSGeneralOutlineView, you’ll need to update the delegate method to include the new parameter.

Here’s the change list for it:

  • Cleaned up the code a bit.
  • Added a new parameter to the delegate method that lets you create a custom drag image.
  • Added a new delegate method that will inform you of a failed drag.

DSGeneralTableView is a NSTableView subclass to go along with my DSGeneralOutlineView class. The two classes are almost identical, with the exception being one delegate method which calls with a row number for DSGeneralTableView rather than with an item with DSGeneralOutlineView.

The class references I wrote up are included in the download file for the respective classes, and are also available for viewing online:

DSClickableURLTextField Class Reference
DSGeneralOutlineView Class Reference
DSGeneralTableView Class Reference

Hope y’all enjoy the updates, and happy coding. :)

Comments are closed.