iink SDK on Device

Answered

Questions about positioning of Text Blocks in TextDocument

I have a few questions about the positioning of Text blocks in a TextDocument.

1- There are cases where the app needs to add or modify the text in a text block programmatically. For example, if we provide a keyboard to the user to allow them to insert or edit text, we will use the input from the keyboard to change the contents of the current text block. The only way we found to do this is to delete the original text block and create a new one with the new text using Editor.addBlock().

addBlock() takes x and y coordinates for the position of the block, but it seems to ignore the value of x and always adds the block to the left of the page. For example, I tried running the following command and a text block with the specified text was inserted in the middle of the page vertically but on the left horizontally.


String message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor " +
                "incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud";
editor.addBlock(200, 500, "Text", MimeType.TEXT, message);

2- Is there a way to specify the width of a text block? The width seems to be based on the text in the block and the location of blocks next to it, is there a way to specify that width ourselves?

3- Is there a way to move an existing block to a different location. The only way we can think of is to delete the block and create a new one at a specified location, but then we run into issue #1.

4- Automatic sizing of new text blocks. We made some experiments with creating new blocks and found the following:
The block will try to take the whole width of the screen.
If there is another block to its right, the block will extend until it reaches that other block and then expand to the bottom if there is more text to be displayed. The block to the right does not move.
If there is a block under it, that other block will move lower to allow our block to expand to fit its text.
The text will be formatted to have line breaks at the location of white spaces, but some words might visually extend outside the limits of the block.
Is the above exact, and are there other rules that we missed?

Best Answer

Hello Nicolas,


Question 1 and 4:


You shall imagine the "Text Document" part splitted into columns. These are basically used to have a proper indentation of the notes. What happens is that when the ink is reflown, it is aligned on  these columns. They are also used for the block positions.


When creating a new block, the engine will take the whole available space, therefore  

  • if you add a block on an empty line, the x is ignored as the block is created with the full line width
  • If you add a block near an existing column , then the x is taken into account 


Question 2:

No it is not possible to specify the width and height as the engine takes the whole available space


Question 3:
Programmatically, it is indeed the way to do it.



Best regards,


Gwenaëlle

1 Comment

Answer

Hello Nicolas,


Question 1 and 4:


You shall imagine the "Text Document" part splitted into columns. These are basically used to have a proper indentation of the notes. What happens is that when the ink is reflown, it is aligned on  these columns. They are also used for the block positions.


When creating a new block, the engine will take the whole available space, therefore  

  • if you add a block on an empty line, the x is ignored as the block is created with the full line width
  • If you add a block near an existing column , then the x is taken into account 


Question 2:

No it is not possible to specify the width and height as the engine takes the whole available space


Question 3:
Programmatically, it is indeed the way to do it.



Best regards,


Gwenaëlle