p.isSelected()

57 views
Skip to first unread message

Robert Cholette

unread,
Sep 13, 2019, 1:26:18 PM9/13/19
to leo-editor
while developping the leo-Integration plugin for vsCode,  the only one thing  that did not work from leoBridge is "p.isSelected()" as I'm trying to set the right selected node upon opening a leo file in the plugin i'm developing in vscode. is this the right function for that? or should i just compare each node to c.p to check if it's the currently selected node?)

Thanks! 
--
Félix

Robert Cholette

unread,
Sep 15, 2019, 2:04:39 AM9/15/19
to leo-editor
Figured it out myself, made it work with this code (trying to set the 'selected' property of 'w_ap' if p is the currently selected node): 

    if p == commander.p:
        w_ap['selected'= True

Latest version of leoInteg implements  the 'getParent' method which is a requirement in vscode to have the powerful 'reveal' functionality in the tree. I try it out in the public test() method, with the 'getSelectedNode' function. 

I've yet to implement body/outline editing and manipulation having any effect on leo's side of things, but I think its going to be trivial once this basic 2 way communication and gui rendering is more fleshed out. 

vitalije

unread,
Sep 15, 2019, 9:14:56 AM9/15/19
to leo-editor
It seems that p.isSelected is actually never used in Leo core. Most probably it is just a remnant from ancient times.
To get currently selected position you can use c.p, and if you wish to check if certain position p is the selected one, use: p == c.p.

Vitalije

vitalije

unread,
Sep 15, 2019, 9:20:40 AM9/15/19
to leo-editor


On Sunday, September 15, 2019 at 3:14:56 PM UTC+2, vitalije wrote:
It seems that p.isSelected is actually never used in Leo core. Most probably it is just a remnant from ancient times.

Curiously enough, both: p.setSelected, p.isSelected delegate to v.isSelected and v.setSelected. Apart from these delegations no other calls to any of these methods is found inside Leo core. I haven't searched for them inside plugins and other places. But it seems that Leo would work properly even without those methods.

Vitalije

Robert Cholette

unread,
Sep 15, 2019, 12:27:51 PM9/15/19
to leo-editor
Thank you, indeed comparing a position to commander.p, or as you guys call it, c.p, did the trick.

Edward K. Ream

unread,
Sep 15, 2019, 6:58:05 PM9/15/19
to leo-editor
On Sun, Sep 15, 2019 at 1:04 AM Robert Cholette <felix...@gmail.com> wrote:
Figured it out myself, made it work with this code (trying to set the 'selected' property of 'w_ap' if p is the currently selected node): 

Good work.  I'm not sure I would have been any help.

Edward

Edward K. Ream

unread,
Sep 15, 2019, 7:01:11 PM9/15/19
to leo-editor
On Sun, Sep 15, 2019 at 8:20 AM vitalije <vita...@gmail.com> wrote:

Curiously enough, both: p.setSelected, p.isSelected delegate to v.isSelected and v.setSelected. Apart from these delegations no other calls to any of these methods is found inside Leo core. I haven't searched for them inside plugins and other places. But it seems that Leo would work properly even without those methods.

I suspect you are correct. What you must not ever do is change any of Leo's selection methods. They are surprisingly fragile.

Edward
Reply all
Reply to author
Forward
0 new messages