Draggable Elements for Token Field like Mac clock format panel
I need to be able to make a token field with draggable elements like the Mac clock format panel (see the 开发者_运维百科following image).
Thanks so much, Alex.
They're called token fields. Apple has a guide for them. (Without knowing any more details of your goals, that's about as precise as I can get.)
Edit
I noticed the edits to your question. You want something that behaves like System Preference's date panel. Here's a breakdown of what I imagine is happening:
- In the "Time Elements* section, there are objects (models) that implement the pieces of data you can use in the text field (hours, minutes, seconds, etc.).
- There is also an associated view for drawing these elements in the same style as the token (maybe taken from something in Cocoa, maybe a custom view).
NSTokenField
objects can accept arbitrary objects, as well as strings. So you can drag these objects from the "Time Elements" section onto the token field. The token field's delegate than handles these non-string objects.
The guide linked above contains the information for handling non-string elements in token fields. I imagine all you need to do is create models for the data parts you want to represent, and then render them using a (possibly custom) view.
精彩评论