Commit 506316b
committed
Fix input harvester scrolling bug
When a dialog is large enough to create scroll bars, and the dialog
contains a message widget (String with visibility=MESSAGE), the dialog's
view would snap back to scroll the first such message widget into view.
It happens when setText is called on the widget's JTextArea, even when
the text being set is the same as it was previously. I'm guessing this
is a bug in Java somehow. Not sure whether the snap-back is intended to
occur when the text changes, but in the case of SciJava message
parameters, the text typically never changes, so we can avoid the issue
in the vast majority of scenarios by only calling setText when the text
*has* actually changed.
Unfortunately, a JTextPane in text/html mode is backed by some pretty
fancy logic that normalizes the input HTML, such that the final assigned
text does not precisely match the input text. For example:
Hello
becomes something like:
<html>
<body>
Hello
</body>
</html>
and then a naive string comparison fails. To work around this fact,
this patch introduces a dummy JTextPane for the sole purpose of
filtering the input text, so that it can be compared against the real
JTextPane's current text before we attempt to assign it needlessly.
Closes #74.1 parent 608b935 commit 506316b
File tree
1 file changed
+20
-1
lines changed- src/main/java/org/scijava/ui/swing/widget
1 file changed
+20
-1
lines changedLines changed: 20 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
127 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
128 | 147 | | |
129 | 148 | | |
0 commit comments