#967 Text in Pop Ups selectable
Some checks are pending
CI / build (windows-latest) (push) Waiting to run
CI / build (macos-13) (push) Waiting to run
CI / build (ubuntu-latest) (push) Waiting to run
Codacy Coverage Reporter / Publish coverage (push) Waiting to run
CodeQL / Analyze (java) (push) Waiting to run

This commit is contained in:
nsec1 2024-06-23 19:31:15 -03:00 committed by GitHub
parent 0a67b9a423
commit 3cac6d7c69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 46 additions and 10 deletions

View file

@ -1200,6 +1200,19 @@ textfield */
-fx-border-color: -bs-background-gray; -fx-border-color: -bs-background-gray;
} }
.text-area-no-border {
-fx-border-color: -fx-control-inner-background;
}
.text-area-no-border .content {
-fx-background-color: -fx-control-inner-background;
}
.text-area-no-border:focused {
-fx-focus-color: -fx-control-inner-background;
-fx-faint-focus-color: -fx-control-inner-background;
}
/******************************************************************************* /*******************************************************************************
* * * *
* Tab pane * * Tab pane *

View file

@ -33,6 +33,7 @@ import haveno.desktop.components.AutoTooltipCheckBox;
import haveno.desktop.components.AutoTooltipLabel; import haveno.desktop.components.AutoTooltipLabel;
import haveno.desktop.components.BusyAnimation; import haveno.desktop.components.BusyAnimation;
import haveno.desktop.main.MainView; import haveno.desktop.main.MainView;
import haveno.desktop.util.CssTheme;
import haveno.desktop.util.FormBuilder; import haveno.desktop.util.FormBuilder;
import haveno.desktop.util.GUIUtil; import haveno.desktop.util.GUIUtil;
import haveno.desktop.util.Layout; import haveno.desktop.util.Layout;
@ -41,6 +42,8 @@ import javafx.animation.Interpolator;
import javafx.animation.KeyFrame; import javafx.animation.KeyFrame;
import javafx.animation.KeyValue; import javafx.animation.KeyValue;
import javafx.animation.Timeline; import javafx.animation.Timeline;
import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener; import javafx.beans.value.ChangeListener;
@ -56,6 +59,7 @@ import javafx.scene.control.Button;
import javafx.scene.control.CheckBox; import javafx.scene.control.CheckBox;
import javafx.scene.control.Hyperlink; import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.Tooltip; import javafx.scene.control.Tooltip;
import javafx.scene.control.ScrollPane; import javafx.scene.control.ScrollPane;
import javafx.scene.control.ScrollPane.ScrollBarPolicy; import javafx.scene.control.ScrollPane.ScrollBarPolicy;
@ -163,7 +167,8 @@ public abstract class Overlay<T extends Overlay<T>> {
protected boolean useAnimation = true; protected boolean useAnimation = true;
protected boolean showScrollPane = false; protected boolean showScrollPane = false;
protected Label headlineIcon, copyIcon, headLineLabel, messageLabel; protected TextArea messageTextArea;
protected Label headlineIcon, copyIcon, headLineLabel;
protected String headLine, message, closeButtonText, actionButtonText, protected String headLine, message, closeButtonText, actionButtonText,
secondaryActionButtonText, dontShowAgainId, dontShowAgainText, secondaryActionButtonText, dontShowAgainId, dontShowAgainText,
truncatedMessage; truncatedMessage;
@ -847,20 +852,37 @@ public abstract class Overlay<T extends Overlay<T>> {
protected void addMessage() { protected void addMessage() {
if (message != null) { if (message != null) {
messageLabel = new AutoTooltipLabel(truncatedMessage); messageTextArea = new TextArea(truncatedMessage);
messageLabel.setMouseTransparent(true); messageTextArea.setEditable(false);
messageLabel.setWrapText(true); messageTextArea.getStyleClass().add("text-area-no-border");
messageTextArea.sceneProperty().addListener((o, oldScene, newScene) -> {
if (newScene != null) {
// avoid javafx css warning
CssTheme.loadSceneStyles(newScene, CssTheme.CSS_THEME_LIGHT, false);
messageTextArea.applyCss();
var text = messageTextArea.lookup(".text");
messageTextArea.prefHeightProperty().bind(Bindings.createDoubleBinding(() -> {
return messageTextArea.getFont().getSize() + text.getBoundsInLocal().getHeight();
}, text.boundsInLocalProperty()));
text.boundsInLocalProperty().addListener((observableBoundsAfter, boundsBefore, boundsAfter) -> {
Platform.runLater(() -> messageTextArea.requestLayout());
});
}
});
messageTextArea.setWrapText(true);
Region messageRegion; Region messageRegion;
if (showScrollPane) { if (showScrollPane) {
scrollPane = new ScrollPane(messageLabel); scrollPane = new ScrollPane(messageTextArea);
scrollPane.setHbarPolicy(ScrollBarPolicy.NEVER); scrollPane.setHbarPolicy(ScrollBarPolicy.NEVER);
scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED); scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
scrollPane.setFitToWidth(true); scrollPane.setFitToWidth(true);
messageRegion = scrollPane; messageRegion = scrollPane;
} else } else
messageRegion = messageLabel; messageRegion = messageTextArea;
GridPane.setHalignment(messageRegion, HPos.LEFT); GridPane.setHalignment(messageRegion, HPos.LEFT);
GridPane.setHgrow(messageRegion, Priority.ALWAYS); GridPane.setHgrow(messageRegion, Priority.ALWAYS);
@ -892,7 +914,7 @@ public abstract class Overlay<T extends Overlay<T>> {
} }
private void addReportErrorButtons() { private void addReportErrorButtons() {
messageLabel.setText(Res.get("popup.reportError", truncatedMessage)); messageTextArea.setText(Res.get("popup.reportError", truncatedMessage));
Button logButton = new AutoTooltipButton(Res.get("popup.reportError.log")); Button logButton = new AutoTooltipButton(Res.get("popup.reportError.log"));
GridPane.setMargin(logButton, new Insets(20, 0, 0, 0)); GridPane.setMargin(logButton, new Insets(20, 0, 0, 0));

View file

@ -26,7 +26,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static haveno.desktop.util.FormBuilder.addMultilineLabel;
public class DisplayAlertMessageWindow extends Overlay<DisplayAlertMessageWindow> { public class DisplayAlertMessageWindow extends Overlay<DisplayAlertMessageWindow> {
private static final Logger log = LoggerFactory.getLogger(DisplayAlertMessageWindow.class); private static final Logger log = LoggerFactory.getLogger(DisplayAlertMessageWindow.class);
@ -41,6 +40,7 @@ public class DisplayAlertMessageWindow extends Overlay<DisplayAlertMessageWindow
type = Type.Attention; type = Type.Attention;
} }
@Override
public void show() { public void show() {
width = 768; width = 768;
// need to set headLine, otherwise the fields will not be created in addHeadLine // need to set headLine, otherwise the fields will not be created in addHeadLine
@ -75,7 +75,8 @@ public class DisplayAlertMessageWindow extends Overlay<DisplayAlertMessageWindow
private void addContent() { private void addContent() {
checkNotNull(alert, "alertMessage must not be null"); checkNotNull(alert, "alertMessage must not be null");
addMultilineLabel(gridPane, ++rowIndex, alert.getMessage(), 10); message(alert.getMessage());
addMessage();
if (alert.isSoftwareUpdateNotification()) { if (alert.isSoftwareUpdateNotification()) {
String url = "https://haveno.exchange/downloads"; String url = "https://haveno.exchange/downloads";
HyperlinkWithIcon hyperlinkWithIcon = FormBuilder.addLabelHyperlinkWithIcon(gridPane, ++rowIndex, HyperlinkWithIcon hyperlinkWithIcon = FormBuilder.addLabelHyperlinkWithIcon(gridPane, ++rowIndex,

View file

@ -89,7 +89,7 @@ public class TacWindow extends Overlay<TacWindow> {
protected void addMessage() { protected void addMessage() {
super.addMessage(); super.addMessage();
String fontStyleClass = smallScreen ? "small-text" : "normal-text"; String fontStyleClass = smallScreen ? "small-text" : "normal-text";
messageLabel.getStyleClass().add(fontStyleClass); messageTextArea.getStyleClass().add(fontStyleClass);
// TODO: link to the wiki // TODO: link to the wiki
// HyperlinkWithIcon hyperlinkWithIcon = addHyperlinkWithIcon(gridPane, ++rowIndex, Res.get("tacWindow.arbitrationSystem"), // HyperlinkWithIcon hyperlinkWithIcon = addHyperlinkWithIcon(gridPane, ++rowIndex, Res.get("tacWindow.arbitrationSystem"),