Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8087659

Non-editable TextInputControl has functional but invisible text cursor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P5 P5
    • tbd
    • 8u40
    • javafx
    • Observed on Windows 8.1 x64.

      When setting editable to false on TextArea or TextField, these controls actually still provide a functional text cursor when clicked. The cursor can be moved with the usual cursor keys and will scroll text into view when reaching the borders of the viewport.

      There's just one problem: that cursor is invisible. This behavior is confusing and undesirable. setEditable(false) should either entirely disable cursor functionality, or (my preference) provide a visible cursor as usual so the user can scroll through long lines. Only changing the text content should be disabled.

      Paste the following code into the start method of an empty JavaFX project to get the two TextInputControls with editing disabled. Try clicking in them and keep typing cursor right to see that the cursor is in fact active, and will eventually scroll the text content to the left.

              final String word = "abcdefghijklmnopqrstuvwxyz";
              final String content = String.join(" ", word, word, word, word);
              
              TextField field = new TextField();
              field.setText(content);
              field.setEditable(false);
              
              TextArea area = new TextArea();
              area.setText(content);
              area.setEditable(false);
              
              VBox root = new VBox();
              root.getChildren().addAll(field, area);
              
              Scene scene = new Scene(root, 300, 250);
              
              primaryStage.setTitle("JavaFX Text Test");
              primaryStage.setScene(scene);
              primaryStage.show();

      This is especially confusing in the case of TextArea which shows a horizontal scrollbar... but the left/right cursor keys move the invisible cursor rather than sending scrollbar messages!

            Unassigned Unassigned
            cnahrjfx Christoph Nahr (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Imported: