cocoa - I would like to insert token at the insertion point of the cursor, not the end of the array -


I have a button that adds a token to a NSTokenField. At the end of this field always adds token:

  NSTokenField * currentField = [dispatcher representing object]; // Define which token should be inserted in the field using the sender's tag. Switch to ([sender tag]) {case eFileNameToken_StartDate: [currentField setObjectValue: [[currentField object value] Arraybazing Object: [NSMutableDictionary dictionaryWithObjectsAndKeys: kTokenName_StartDate, kTokenKey_Name, @ "% m-% d-% Y", kTokenKey_Format, [NSNumber number : 0], KTokenKey_FormatIndex, zero]]]; break;  

Because it is grabbing the array with the currentField objectValue and then creating an array by adding the object.

I like to know the insertion point of the cursor and to insert the object in the resulting currentField objectValue, so that I can set the object value of the current field with the correctly ordered token. Thanks for any help yall

So I understood it and I thought that ID is my solution .

Someone needs to grab a field editor and check the selected range

  NSText * textEditor = [currentField current sender];  

This gives you an entry point in the currently edited text field. However, if you have a tokenfield that contains mixed text and tokens together, then you will find that each token is counted as one letter only in selectedRange.

If this is the case then you need to write some arguments to correctly insert the current filtered array.

  1. Step:
    1. Make a temporary NSMutableArray
    2. Fill [currentField objectValue]
    3. Each character in a non-token string For classes of types of tokens, repeat through this temple array, increasing a postian counter, 1 / li>
    4. increases its array index at the end of each loop
    5. Make sure to ensure that the situation is doubled or your [current field editor selected range] Area more. Exit the location and loop
    6. Finally, insert your new token into the temporary array and then [currentField setObjectValue: with that array]

My tokens are associated with a comma NSDictions with $ Token $ style names In this way, when I run my loop, I paint between text and tokens.

Happy :)


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -