0

My page has in its center a Draw2D canvas. It may have a selection or not at any moment.

I need to update the selection manually. When the user (drags and) drops an element from the Toolbox (panel on the left of the page), it creates the element in the canvas. I want this element to be selected. To do so, I made this:

canvas.getSelection().clear().setPrimary(newFigure);

Triggers are attached to selection change. On the right side of the page, I have a Properties panel that shows information on what is selected.

When I drop my element, my UI updates so that the Properties panel's content to match the Figure that was just added. But the fact is that the blue dashed rectangle that is supposed to be around the selected element(s) is not updated. Consequence is that the user might be confused (imagine yourself seeing details on Foo when Bar is selected).

In this case, why isn't the visual selection updated? And how to do so, if it is possible?

V. Courtois
  • 315
  • 7
  • 20

1 Answers1

1

Canvas has a setCurrentSelection method that takes any draw2d.Figure or a draw2d.util.ArrayList of figures

allonym
  • 1,408
  • 10
  • 18
  • If I am not mistaken, `setCurrentSelection()` does the same thing as `canvas.getSelection().setPrimary()`. – V. Courtois Apr 06 '20 at 06:44
  • Perhaps so. I can confirm that setCurrentSelection works for me in the latest version of draw2d though, so maybe the O.P. is having a different issue – allonym Apr 08 '20 at 20:15
  • 1
    Actually I just looked it up, setCurrentSelection is not the same as getSelection().setPrimary(). The former clears the objects from the current selection, then adds the passed-in object or array to the current selection. The former simply sets which one of the currently-selected objects is primary. I would not expect getSelection().setPrimary() to have any effect on the visual state. – allonym Apr 08 '20 at 20:30