Git Product home page Git Product logo

oextokenfield's Introduction

Introduction

OEXTokenField is a subclass of NSTokenField that allows token customization.

How to use

NSTokenField tokens rely on text attachments, which are drawn by instances of NSTextAttachmentCell. OEXTokenField works by subsituting the default text attachment cells as they are inserted with cells provided by its delegate.

In order to provide custom token cells, you just need to implement the following delegation method:

- (NSTextAttachmentCell *)tokenField:(OEXTokenField *)tokenField attachmentCellForRepresentedObject:(id)representedObject;

Any instance of NSTextAttachmentCell is fine. However, if you want to display tokens that look identical or similar to AppKit tokens, you may use and subclass the OEXTokenAttachmentCell class.

Known issues

For the moment, OEXTokenField doesn't provide menus for represented objects that display custom attachment cells.

Source Code

The OEXTokenField code is available from GitHub:

https://github.com/octiplex/OEXTokenField.git

License

OEXTokenField is made available under the Revised BSD License. See the LICENSE file for more info.

oextokenfield's People

Contributors

1337mus avatar baarde avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oextokenfield's Issues

Podspec documentation field is deprecated

The documentation field in the podspec file has been deprecated. I'd have removed that one line and submitted a pull request, but I'm not sure where that appledoc command should be moved to to correctly sunset the documentation feature.

From what I understand cocoadocs.org is intended to be used as a storehouse for CocoaPods documentation.

Using OEXTokenField with custom object

Your implementation works great when using it with strings, but there is an issue when using it with custom objects, I can't figure out where the problem lies.

When using custom objects with token field you're supposed to implement:

- (BOOL)tokenField:(NSTokenField *)tokenField writeRepresentedObjects:(NSArray *)objects toPasteboard:(NSPasteboard *)pboard

Cocoa provides array of strings as the objects parameter so you can use the objects to identify dragged items then write the custom objects to clipboard. But OEXTokenField delegate, for objects param. always provides array of empty strings?
I tested regular NSTokenField and it indeed provides array of strings. Can you post some hints about the problem?
I found out that

OEXTokenTextStorage:
- (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)str

replaces(removes) string but leaves the attributes intact which might be the cause why the objects is array of empty strings, but I'm not sure ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.