Referencing existing ContentBlock in a Text Document
N
Nicolas Morin
started a topic
about 4 years ago
We are looking at ways to manage the ContentBlocks in a Text Document but are having trouble referencing the blocks.
1- We made some experiments with adding text blocks to a "Text Document"
with Editor.addBlock(). We can see the new blocks being added but the
return value of the function is always "null" so we are unable to
reference the new block directly. Is this a bug or are we doing something wrong?
2- Is there some way to get a list of all the existing blocks in a document. We found how to retrieve a block with "hitBlock", but not how to find the blocks directly without "poking" all over the screen. There is also "getBlockById" but we don't know how to set an ID to a newly created block or how to retrieve the IDs of existing blocks.
Thank you!
Best Answer
O
Olivier @MyScript
said
about 4 years ago
Dear Nicolas,
thank your for your questions. To answer these:
1-Currently, I just tried on my side with the iink 1.4, and it worked out of the box:
Indeed we tried adding a Text block using the function you linked to, providing a test string as data. There was no exception and the return value was null. But it might have been with iink 1.3. I just tried again with version 1.4 and was able to get a non-null return value so it seems to be fine.
And thanks for pointing us to getChildren(). This should work for us.
O
Olivier @MyScript
said
about 4 years ago
Dear Nicolas,
thank you for the update, I am glad it is working.
Nicolas Morin
We are looking at ways to manage the ContentBlocks in a Text Document but are having trouble referencing the blocks.
1- We made some experiments with adding text blocks to a "Text Document" with Editor.addBlock(). We can see the new blocks being added but the return value of the function is always "null" so we are unable to reference the new block directly.
Is this a bug or are we doing something wrong?
2- Is there some way to get a list of all the existing blocks in a document. We found how to retrieve a block with "hitBlock", but not how to find the blocks directly without "poking" all over the screen. There is also "getBlockById" but we don't know how to set an ID to a newly created block or how to retrieve the IDs of existing blocks.
Thank you!
Dear Nicolas,
thank your for your questions. To answer these:
1-Currently, I just tried on my side with the iink 1.4, and it worked out of the box:
On your side, which kind of block did you add? A Text one? If so, did you use the following function: https://developer.myscript.com/refguides/interactive-ink/android/1.4/com/myscript/iink/Editor.html#addBlock-float-float-java.lang.String-com.myscript.iink.MimeType-java.lang.String-
Did you add data? D o you have an exception?
2- you can use the following function:
ContentBlock[] blocks=editor.getRootBlock().getChildren();
You can also refer to the following post, that should help: https://developer-support.myscript.com/support/discussions/topics/16000027123
Best regards,
Olivier
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstOlivier @MyScript
Dear Nicolas,
thank your for your questions. To answer these:
1-Currently, I just tried on my side with the iink 1.4, and it worked out of the box:
On your side, which kind of block did you add? A Text one? If so, did you use the following function: https://developer.myscript.com/refguides/interactive-ink/android/1.4/com/myscript/iink/Editor.html#addBlock-float-float-java.lang.String-com.myscript.iink.MimeType-java.lang.String-
Did you add data? D o you have an exception?
2- you can use the following function:
ContentBlock[] blocks=editor.getRootBlock().getChildren();
You can also refer to the following post, that should help: https://developer-support.myscript.com/support/discussions/topics/16000027123
Best regards,
Olivier
Nicolas Morin
Thank you Olivier.
Indeed we tried adding a Text block using the function you linked to, providing a test string as data. There was no exception and the return value was null. But it might have been with iink 1.3. I just tried again with version 1.4 and was able to get a non-null return value so it seems to be fine.
And thanks for pointing us to getChildren(). This should work for us.
Olivier @MyScript
Dear Nicolas,
thank you for the update, I am glad it is working.
Best regards,
Olivier