Inkscape.org
Creating New Extensions Getting ID of element selected in XML-Editor
  1. #1
    Nihilist Nihilist @Nihilist

    Hi, I am not sure if this is buggy behavior or not, but currently selecting certain kinds of elements inside the XML-Editor doesn't seem to update the selected node inside inkscape. Specifically, when I run my extension and use self.options.ids to get the currently selected element, the passed ids will not match with the element selected by the XML-Editor. This seems to affect at least elements stored inside <defs>, but perhaps others too.

     Is there a way to get the ID of the element currently selected in the XML editor?

  2. #2
    inklinea inklinea @inklinea⛰️
    *

    Not that I am aware of. 

    I think it is more the case that the XML editor causes an item to be selected on the canvas, and that item is the ID reported by the extension.

    If you click on a non canvas item such as a <def> item, the highlighting in the XML editor may change, but the selected canvas item should not - so that is the ID reported.

    There are some quirks such as if you select a nested symbol group in the XML editor.

    Nihilist

    when I run my extension and use self.options.ids to get the currently selected element

    You can get a list that way. However the normal way to get selected items is:

    my_selection_list = self.svg.selected

    That returns the current selection list, which you can loop through or address by index : my_selection_list[2] for example

     

  3. #3
    Nihilist Nihilist @Nihilist

    Thanks for the response. It is a bit of a shame. Is there perhaps a good place that I could request such a feature?

Inkscape Inkscape.org Inkscape Forum Creating New Extensions Getting ID of element selected in XML-Editor