CSS id selector with embedded dot

David Grieve david.grieve at oracle.com
Wed May 10 14:02:50 UTC 2017


Having an id with a dot is not valid CSS syntax.

 From the spec: " An ID selector contains a "number sign" (U+0023, #) 
immediately followed by the ID value, which must be an CSS identifiers."

An identifier is defined here: 
https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier. The tldr; 
is that an identifier cannot contain a dot.


On 5/10/17 9:23 AM, Jens Auer wrote:
> Hi,
>
> I am working on a project which enforces unique FX Id by using a naming convention mirroring the hierarchical structure of the controls in the name, delimited by dots. So for example, we have a button "myPane.button1". I am not able to select this button in a css file. Here is an example program and the css file:
>
> import javafx.application.Application;
> import javafx.scene.Scene;
> import javafx.scene.control.Button;
> import javafx.scene.layout.VBox;
> import javafx.stage.Stage;
>
> public class CssTest extends Application {
>
>      public static void main(final String[] args) {
>          Application.launch(args);
>      }
>
>      @Override
>      public void start(final Stage stage) {
>          VBox vbox = new VBox();
>          Button b1 = new Button();
>          b1.setId("the.button");
>          b1.setText("BUTTON1");
>
>          Button b2 = new Button();
>          b2.setId("thebutton");
>          b2.setText("BUTTON2");
>
>          vbox.getChildren().addAll(b1, b2);
>          vbox.getStylesheets().add("stylesheet.css");
>
>          final Scene scene = new Scene(vbox);
>
>          stage.setScene(scene);
>          stage.show();
>      }
> }
> The css file is
>
> #the\.button {
>      -fx-graphic: url("Keyboard.png");
> }
>
> #thebutton {
>      -fx-graphic: url("Keyboard.png");
> }
>
> As far as I understand the CSS definition the names are valid ids and escaping should work here. Is this a limitation in the JavaFX CSS parser?
>
> Best wishes,
> Jens
>
> Jens Auer
> (Softwareentwicklung)
> ___________________________________________________________
> Unternehmensberatung H & D GmbH
> Niederlassung Weißenthurm
> Werftstr. 5 - 56575 Weißenthurm
> Tel.:            02637/94238 -110
> Fax:            02637/94238 -149
> jens.auer at h-d-gmbh.de
> http://www.h-d-gmbh.de
> http://www.h-d-gmbh.de/impressum.html
> ___________________________________________________________
>



More information about the openjfx-dev mailing list