Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: override error bgcolor  (Read 15003 times)
Alessandro (Efisio) R.
Posts: 42


« on: December 22, 2014, 04:39:38 pm »

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
Quote
If 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
Quote
Like 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.
Four Js
Posts: 532


« Reply #1 on: December 23, 2014, 11:36:12 am »

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
  1. FUNCTION my_error(m, s)
  2.   DEFINE m, s STRING
  3.   IF s IS NULL THEN
  4.       ERROR m ATTRIBUTES(NORMAL)
  5.   ELSE
  6.       ERROR m ATTRIBUTES(NORMAL, STYLE=s)
  7.   END IF
  8. END FUNCTION
  9.  
Seb
Alessandro (Efisio) R.
Posts: 42


« Reply #2 on: December 23, 2014, 12:09:36 pm »

Thanks Seb. I thought there was a way to override that attribute without editing all the project.
Reuben B.
Four Js
Posts: 1108


« Reply #3 on: January 04, 2015, 10:51:18 pm »

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.
Four Js
Posts: 532


« Reply #4 on: January 05, 2015, 01:32:16 pm »

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.
Posts: 42


« Reply #5 on: January 05, 2015, 03:10:42 pm »

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.
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines