set style attribute of an embedded

Hi,

I’m using an embedded for displaying an svg-image. I have to set the style attribute, but using “addStyleName” I’m only able to set the style of the surrounding div-container. Is it possible somehow?

greetings and thanks
Chris

You want to set the style attribute or add a class name? Do you have some special reason for setting the style attribute and not just making a CSS rule for it?

The Embedded component is a

element with an inside it. If you really need to manipulate the deeper than with the server-side API, you’d either need to extend the widget or make an component extension for it (with GWT or JavaScript). If you are feeling lazy, I suppose you could also just make some simple JavaScript call to set the attribute.

I have to add ‘style=“pointer-events: none;”’ to the underlying object in order to make elements in the svg not responsible to mouse events. I only want the container div to respond to mouse events (e.g. drag&drop). At first, I will try the JavaScript solution, thank you!

The normal the approach in Vaadin is to use stylenames & CSS to change the styles of elements; from your description, there seems to be no reason why you can’t do that here. The CSS below specifcally targets the element below the .v-embedded with a an added stylename of “foo”.

HTH,

Cheers,

Charles.



java:

    embedded.addStyleName("foo");

css:

    .v-embedded.foo object {
       pointer-events: none;
   }