Open Source JavaFX Now!
Combination View Flat View Tree View
Scaled TextBox problem
toggle
Scaled TextBox problem
font textbox
10/22/09 8:09 PM
Hi,

This problem exists on Windows. Works fine on Mac OS X.

My app requires scaled TextBoxes. I just notice on Windows a scaled TextBox does not handle the content text and the caret position properly, e.g. the caret is placed in the middle of a character instead of in between characters. Just run the code below under Windows and type some really long text. By doing this test I noticed the initial position of the first visible character (and the rest of the text) was shifted left. Also when moving around using the arrow keys reveals that the caret is misplaced. I already reported a Jira issue for that (watiting for acceptance). But I need the scaled TextBoxes as the user zooms in and out in my app and so the TextBox instances should scale accordingly. I can't just change the font size. Any suggestions please?

 1import javafx.stage.Stage;
 2import javafx.scene.Scene;
 3import javafx.scene.text.Font;
 4import javafx.scene.control.TextBox;
 5import javafx.scene.Group;
 6
 7Stage {
 8    title: "TextBox Scaling Problem"
 9    width: 700
10    height: 100
11    scene: Scene {
12        content: [
13                Group {
14                    content:
15            TextBox {
16                font : Font {
17                    size : 13
18                    name: "Courier"
19                }
20                columns: 30
21                layoutX: 100
22                layoutY: 20
23                scaleX: 1.7
24                scaleY: 1.7
25            }
26
27            }
28        ]
29    }
30}
Flag Flag
RE: Scaled TextBox problem
11/1/09 2:40 PM as a reply to Lukasz Berg.
You can change the font size, but sneakily - code below shows difference as it has the positioning advantage too, as positioning gets - yes I will use the word - CORRUPTED - when scaling:

 1import javafx.stage.Stage;
 2import javafx.scene.text.Font;
 3import javafx.scene.control.TextBox;
 4import javafx.scene.control.Slider;
 5import javafx.scene.Scene;
 6import javafx.geometry.HPos;
 7import javafx.scene.layout.VBox;
 8
 9var slider = Slider {
10    value: 1
11    min: 1
12    max: 4
13    majorTickUnit: 1
14    clickToPosition: true
15    showTickLabels: true
16    showTickMarks: true
17    };
18
19var font = Font { size : 13 name: "Courier" };
20var scaleWatch = bind slider.value on replace { font = Font { size: 13 * slider.value, name: "Courier" }; };
21
22Stage {
23    title: "TextBox Scaling Problem"
24    width: 700
25    height: 200
26    scene: Scene {
27        content: [
28            VBox {
29                layoutX: 10
30                layoutY: 10
31                spacing: 10
32                hpos: HPos.LEFT
33                content: bind [
34                    TextBox {
35                        font :  Font { size : 13 name: "Courier" }
36                        columns: 30
37                        scaleX: bind slider.value
38                        scaleY: bind slider.value
39                        },
40                    TextBox {
41                        font : bind font
42                        columns: 30
43                        },
44                     slider,
45                    ]
46                }
47            ]
48        }
49    }


Sorry for late reply, you have probably sorted anyway,

P.S. Slider just about works, for some reason I have never ever managed to get the slider behaving as I think it should :-(

Cheers,

David
Flag Flag
RE: Scaled TextBox problem
255
11/3/09 10:52 AM as a reply to David Armitage.
Hi David,

Thanks for the reply. Yep, scaling using the font size just works. However, as I mentioned at the end of my previous post, I cannot use it. The scene of my app consists of not only TextBoxes and I have have a requirement that the scene should be zoomable. So, the vector scaling (scaleX & scaleY or the Node transforms) seems to be the first choice.
The bad news is I reported this issue via JavaFX Jira twice already in the last 2-3 weeks and it seems to be silently dropped. Hopefully it is a well known problem and it is dropped due to a duplication.

It's a slider bug. There is a couple of issues reported on it and many of them are already fixed, so I hope we will get a better slider in SoMa release.

I love the idea of JavaFX and won't give up on it, now, but it should not be called 1.x release, in my opinion.

Cheers,
Lukasz
Flag Flag