override error bgcolor

Started by Alessandro (Efisio) R., December 22, 2014, 04:39:38 PM

Previous topic - Next topic

Alessandro (Efisio) R.

Hi,

I am trying to set a background color to all error messages with the pseudo selector "Message:error".

From ERROR instruction section of the BDL manual
QuoteIf you want to apply automatically a style to all program warnings displayed with the ERROR instruction, you can use the :error pseudo selector in the style definition.

From message style attributes section of the BDL manual
QuoteLike simple form fields, TTY attributes have a higher priority than style attributes. By default, ERROR has
the TTY attribute REVERSE, which explains why ERROR messages have a reverse background even when
you use a backgroundColor style attribute.

So, if I want to apply a background color only with a style attribute without adding on every ERROR instruction any option and overriding the default tty style?

Thanks,
Alessandro.

Sebastien F.

Hello,

Consider centralizing your ERROR instructions in a function, and use ATTRIBUTES(NORMAL) to remove the default REVERSE TTY attribute, and have your style background color applied... for example:

Code (genero) Select
FUNCTION my_error(m, s)
   DEFINE m, s STRING
   IF s IS NULL THEN
       ERROR m ATTRIBUTES(NORMAL)
   ELSE
       ERROR m ATTRIBUTES(NORMAL, STYLE=s)
   END IF
END FUNCTION

Seb

Alessandro (Efisio) R.

Thanks Seb. I thought there was a way to override that attribute without editing all the project.

Reuben B.

Seb,

Mathematically what does the REVERSE attribute actually do?

When I first read this thread, my first instinct was that even if ERROR had an implicit REVERSE attribute, that this could be overcome by simply swapping the values of the textColor and backgroundColor attributes in the .4st, or perhaps set the RGB colour values in the style to be a ones complement of the desired RGB colour value, however neither of these techniques worked.  It was as if the implicit REVERSE was setting a hard-coded grey as the background-color.

Looking forward, is the implicit REVERSE actually required?.  It seems an unnecessary complication that could perhaps be removed and replaced with a suitable entry in default.4st if needed. 

Reuben
Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero

Sebastien F.

Reuben,

When using a REVERSE TTY attribute in the code, the VM just sets a dedicated "reverse" attribute in the AUI node for the element. We have other TTY attributes such as "blink", "underline", "color" ...

The rendering of these TTY attributes is then in the hands of the front-ends, for "reverse", front-ends can mimic what you could get on dumb terminals with "reverse video" character highlighting.

ERROR has been implemented with an implicit "reverse" attribute, because in I4GL text mode, the error message displays in reverse-video.

Swapping textColor/backgroundColor does not help, because element-specific TTY attributes have a higher precedence as style attributes.
(see https://4js.com/online_documentation/fjs-fgl-manual-html/?path=fjs-fgl-manual#c_fgl_presentation_styles_013.html)

Maybe we could have had a global option, to define the default TTY attributes for ERROR:

   OPTIONS ERROR ATTRIBUTES(NORMAL)

Centralizing error message display in a function is anyway a good pattern to me.

Seb

Alessandro (Efisio) R.

Reading the BDL manual, the NORMAL tty attribute appears to be a font attribute instead of REVERSE, which is a video attribute. And this is why applying your suggestion and centralizing with a function that uses ERROR ATTRIBUTES (NORMAL, STYLE...) doesn't let me choose a textColor in the Message:error. I partially resolved using the BLINK attribute, which doesn't make any graphical effect in GUI mode and maybe overrides some other 4st styles that are useless for me.