Four Js Development Tools Forum

Discussions by product => Genero BDL => Topic started by: Graham H. on December 10, 2008, 11:28:30 am



Title: Dynamically created buttons
Post by: Graham H. on December 10, 2008, 11:28:30 am
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.


Title: Re: Dynamically created buttons
Post by: Sebastien F. on December 10, 2008, 11:57:11 am
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