On Sat, 15 Oct 2005 19:27:47 -0400 dan sinclair <[EMAIL PROTECTED]> babbled:

> I've been working to port EWL to textblock2 and it's coming along pretty
> well, but I've run into an issue. When I try to setup my triggers (for
> areas that get mouse overs and that kind of thing) they don't seem to be
> working.
> 
> The way I'm doing this is to do:
> 
>         cur1 = evas_object_textblock2_cursor_new(t->textblock);
>         cur2 = evas_object_textblock2_cursor_new(t->textblock);
> 
>         evas_textblock2_cursor_pos_set(cur1, tb_pos_start);
>         evas_textblock2_cursor_pos_set(cur2, tb_pos_end);
> 
>         /* get all the rectangles and create areas with them */
>         rects = evas_textblock2_cursor_range_geometry_get(cur1, cur2);
> 
> Except rects is always NULL. I've check tb_pos_start and tb_pos_end and
> they both have numbers that make sense. So, I took a look a the
> textblock2 code and ended up looking at evas_textblock2_cursor_pos_set
> and wondering, what the hell?
> 
> void    
> evas_textblock2_cursor_pos_set(Evas_Textblock_Cursor *cur, int pos)
> {       
>    if (!cur) return;
>    if (!cur->node) return;
>    if (cur->node->type == NODE_FORMAT) pos = 0;
>    if (pos < 0) pos = 0;
>    else if (pos > cur->node->len) pos = cur->node->len;
>    cur->pos = pos;  
> }                      
>       
> This will only move the position of the cursor inside the node it is
> currently pointing too? Is that useful? I'd expect, given the name, that
> it would position the cursor inside the textblock at the given position,
> not in whatever node it's pointing too.
> 
> If this isn't a bug, what is the correct way I should be doing my EWL
> code above?

aaah! i see a bit of confusion. it places the cursors at CHARACTER BYTE "pos"
IN the node it is looking at. you need to select the text node first - it is
pointing at none to start with. jump to thefirst node (or whatever node). in
tb2 unlike tb1 everything is divided into nodes. a node is either a format node
or a text node. you can walk the node list using calls (u'll see them). tb2
doesnt deal in absolute character positons from the start of the tb - its
relative to the node start. basically i suggest that when u insert a text node
and there should be anchors, a great way to do this is insert an empty format
like " " before and after the anchor, then get the node which the anchor text
is in (go to the last node, walk back 1 from there and you are looking at it,
and set the cursor to the node start evas_textblock2_cursor_char_first()).do
this with 1 cursor u created, then make a copy of that cursor and jump it to
the end of the node evas_textblock2_cursor_char_last() and now you have it
nicely isolated :) just keel those 2 cursors around. delete them when you
delete the tb - they will move around with the text as u insert or delete etc.
like a real cursor would, and when u need to find the geometry that anchor uses
query it and get a list of rects in return :)



-- 
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler)    [EMAIL PROTECTED]
裸好多
Tokyo, Japan (東京 日本)


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to