Notes on using TextBlock:

After appending strings to the block,

evas_textblock_cursor_node_first(Cursor);

moves the cursor back to the beginning of the text. This is generally equivalent to:

evas_textblock_cursor_line_set(Cursor,0);
evas_textblock_cursor_pos_set(Cursor,0);

Functions such as "pos_set" and "char_first" operate within the current line. They do not cross line boundaries. Both lines and character positions are counted from zero.

If you want to have a visible cursor, the function:

evas_textblock_cursor_char_geometry_get(Cursor, &PosX, &PosY, &Width &Height);

gives you the pixel coordinates and size of the character box at the cursor position which can be used to resize and move a graphic image to superimpose it on the character. These coordinates are referenced to the edge of the textblock object so you may have add margins when you use "evas_object_move()" which is referenced to the canvas. Resizing to "Height" will accommodate different fonts but some proportional characters are very narrow so the width of the graphic cursor image should be set as a proportion of the height rather that using the width value returned by the geometry function. This function will fail and return -1 if the cursor is positioned at the end of a line or on a blank line.

It is easy to set up a timer callback function to toggle between "object_show" and "object_hide" to make the cursor blink. Don't forget that the callback function has to return 1 to make the timer cycle.

The cursor image must have a transparent background so you have to use a format such as PNG which supports that. JPEG does not. I could not find a good cursor image and had to make one up. I have attached it so maybe it will save someone some time.

Now I have to figure out how to position the text cursor in response to a mouse click. At the moment, the only thing I have come up with is to use the "geometry" functions to scan down for the line and then across for the character. There must be a better way and if anyone knows one, I would like to hear about it!

Mike
------------------------------------------------------------------------------
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to