KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Applying Stylesheets Selectors
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: July 15, 2024

4D form objects that display characters can have the font and display formated. The format can be applied directly or by using a predefined set called a stylesheet. Setting up and applying stylesheets can be useful as it can allow for more consistency across the 4D database and it will allow ease of formatting new objects by applying the stylesheet property which will apply the formatting.

This feature may not have been taken advantage of in older databases, but if the database is being converted to project mode this feature may be able to be applied. With project mode, stylesheets are defined as a separate CSS file. Using CSS, specific conditionals can be applied to specify which set of styles should be applied besides a name based on Stylesheet selectors.

Below is the list of acceptable object selectors:

  • button
  • buttonGrid
  • checkbox
  • combo
  • dropdown
  • groupBox
  • input
  • line
  • list
  • listbox
  • oval
  • picture
  • pictureButton
  • picturePopup
  • plugin
  • progress
  • radio
  • rectangle
  • ruler
  • spinner
  • splitter
  • stepper
  • subform
  • tab
  • text
  • view
  • webArea
  • write

For example, 4D provides a "Default" style. By updating the CSS, a specific default style can be defined for text objects and another one for buttons.
When converted the CSS file should contain the definition for the "Default" style:

   .Default { ... }

Copy and paste additional copies of it and specify the object type. The following is an example of a "Default" style sheet for text form objects, another for button form objects, and a generic one for all other objects.

   text.Default { ... }

   button.Default { ... }

   .Default { ... }