4D v16.3SVG SET ATTRIBUTE |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v16.3
SVG SET ATTRIBUTE
SVG SET ATTRIBUTE
The SVG SET ATTRIBUTE command is used to modify the value of an existing attribute in the SVG rendering tree of a displayed image or in the internal DOM tree of an image. If you pass the optional * parameter, you indicate that the pictureObject parameter is an object name (string). In this case, the command applies to the parameters of the rendered image attached to the object (note that the parameters and therefore the rendered image of the object are only created if the SVG SET ATTRIBUTE command is called at least once). By default, modifications made by this command apply only to the rendered images; they are not stored in the data source (internal DOM tree) and are lost when the picture is erased by programming or when the form is closed. However, you can transfer these changes into the internal DOM tree of the image when the pictureObject parameter references a variable: you just need to pass the second * as the last parameter. This lets you keep the modifications made on the fly. Notes:
The element_ID parameter is used to specify the ID ("id" or "xml:id" attribute) of the element whose attribute(s) you want to modify. In the attribName and attribValue parameters, pass, respectively, the attribute to set and its value (as variables, fields or literal values). You can pass as many attribute/value pairs as you want. The SVG SET ATTRIBUTE command is used to modify (but not to add or delete) most of the SVG attributes, such as, for instance, 'fill', 'opacity', 'font-family', and so on. For a complete definition of the SVG attributes, please refer to the reference documents available on the Internet, for example: http://www.w3.org/TR/SVG11/attindex.html. The rendered image is updated immediately; the modifications are transferred on to the child elements for inherited styles. Note that for technical reasons, the attributes of certain elements as well as certain attributes cannot be modified. The following table lists the elements that can be modified, and those that cannot, as well as the attributes that cannot be modified: Elements whose attributes can be modified
Elements whose attributes cannot be modified
Attributes that cannot be modified
(1) These attributes cannot be modified because they define and structure the resulting image. The width and height attributes of the svg element are used to define the initial dimensions of the picture in 4D and these dimensions must remain constant after the picture is created (it is however possible to modify the dimensions of the resulting picture with the TRANSFORM PICTURE command of 4D). You can also refer to the description of the SVG GET ATTRIBUTE command to see the list of 4D attributes that are reserved and dedicated to animation. If you attempt to modify the attribute of an element that is not supported or one of its child elements, the command does nothing and no error is generated. If the command is not executed in the context of a form or if an invalid pictureObject is passed, the OK variable is set to 0. If the command has been executed correctly, it is set to 1. Modification of the contents of a Text type element: SVG SET ATTRIBUTE(*;picture_object_name;text_element_ID;"4d-text";"This is a text") Note: There is no namespace in order that the attribute could be used in a CSS style sheet without risk of conflict.
See also
|
PROPERTIES
Product: 4D HISTORY
Created: 4D v12 ARTICLE USAGE
4D Language Reference ( 4D v16) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||