KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Inverting color example
PRODUCT: 4D | VERSION: 14.3 | PLATFORM: Mac & Win
Published On: March 26, 2015

Inverting color is possible in a 4D object. With the help of Tech Tip #77244 (Inverting a Long Int number), the object's color can be inverted. An example is shown below by hovering the mouse pointer over a variable object.

The variable object would need to activate the Mouse Enter and Mouse Leave events as shown below in red:



Then adding the following code in the variable object method and using INVERT_LONGINT:

C_LONGINT(bgColor;fgColor;altColor)

Case of
   : (Form event=On Mouse Enter)

   OBJECT GET RGB COLORS(*;OBJECT Get name(Object current);bgColor;fgColor;altColor)

   If ((bgColor=-1) & (fgColor=-2)) // Default color of variable object
      OBJECT SET RGB COLORS(*;OBJECT Get name(Object current);16777215;0)
   Else
      OBJECT SET RGB COLORS(*;OBJECT Get name(Object current);bgColor;INVERT_LONGINT (fgColor);altColor)
   End if

   : (Form event=On Mouse Leave)
   OBJECT SET RGB COLORS(*;OBJECT Get name(Object current);bgColor;fgColor)
end case


The example shown used a fill color of green:


When the mouse is over the object the color changes to blue: