On Wed, 17 Apr 2013 12:09:52 -0700 (PDT)
SegundoBob <[email protected]> wrote:

> This thread gives a recipe for inserting text into the body of a node
> at the current cursor:
> 
> http://groups.google.com/group/leo-editor/browse_thread/thread/a08d122e0cf59359/60be2b02f3ef3e94
> 
> Unfortunately, this recipe has a problem:  When focus is moved away
> from and then back to the modified node, the inserted text
> disappears.  That is, Leo-Editor seems unaware of the insertion.
> 
> The following recipe fixes this problem:
> 
> http://pastebin.com/GAc15jRL
> 
> Is this recipe the right way to do it or is there a better way?

I think that's the way, see also:

https://groups.google.com/forum/?fromgroups=#!searchin/leo-editor/insert$20text$20will$20disappear$20after$20insert$20children$20node$20and$20redraw/leo-editor/0haTWrUlNVg/lFU1JkMHrosJ

Depending on your use you might want to
   
    oldins = w.getInsertPoint() 

    ...

    w.setInsertPoint(oldins+len(inserted_text)) 

to get the cursor where you want it afterwards, lots of variations how
the new position might be calculated.

Other possibly useful methods:

    i,j = w.getSelectionRange(sort=True)
    s = w.getSelectedText()  

Cheers -Terry

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to