Dynamically created buttons

Started by Graham H., December 10, 2008, 11:28:30 AM

Previous topic - Next topic

Graham H.

I have code which correctly creates buttons on the screen.
However, the statement b.setAttribute("backgroundColor", "red") crahes the application with the error
"The attribute backgroundColor does not belong to node Button", which is untrue since it can be defined in a style.
Similarly a button defined in a .per file can have "justify = center" which puts the text in the middle of the button.  The facility appears to be unavailable as a style attribute.

Sebastien F.

Graham,

The backgroundColor attribute is not an attribute of Button, so it's normal that you get this error.

The purpose of styles is to define decoration attributes indirectly through a style name.

You should define a style for your buttons defining the backgroundColor attribute, then set the style attribute in programs with:

   CALL form.setElementStyle("name", "mystyle")

https://4js.com/techdocs/genero/fgl/devel/DocRoot/User/ClassForm.html#setElementStyle

Seb