修复部分按钮点击后始终保持焦点状态的问题 (#4585)

This commit is contained in:
Wulian233
2025-10-04 21:16:35 +08:00
committed by GitHub
parent 411efbe774
commit c60af8675f
2 changed files with 15 additions and 5 deletions

View File

@@ -100,7 +100,10 @@ public abstract class ToolbarListPageSkin<T extends ListPageBase<? extends Node>
ret.getStyleClass().add("jfx-tool-bar-button"); ret.getStyleClass().add("jfx-tool-bar-button");
ret.setGraphic(wrap(svg.createIcon(Theme.blackFill(), -1))); ret.setGraphic(wrap(svg.createIcon(Theme.blackFill(), -1)));
ret.setText(text); ret.setText(text);
ret.setOnAction(e -> onClick.run()); ret.setOnAction(e -> {
onClick.run();
ret.getScene().getRoot().requestFocus();
});
return ret; return ret;
} }

View File

@@ -19,7 +19,8 @@ package org.jackhuang.hmcl.ui.download;
import com.jfoenix.controls.*; import com.jfoenix.controls.*;
import javafx.beans.InvalidationListener; import javafx.beans.InvalidationListener;
import javafx.beans.property.*; import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.geometry.Insets; import javafx.geometry.Insets;
@@ -49,7 +50,10 @@ import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.SVG; import org.jackhuang.hmcl.ui.SVG;
import org.jackhuang.hmcl.ui.animation.ContainerAnimations; import org.jackhuang.hmcl.ui.animation.ContainerAnimations;
import org.jackhuang.hmcl.ui.animation.TransitionPane; import org.jackhuang.hmcl.ui.animation.TransitionPane;
import org.jackhuang.hmcl.ui.construct.*; import org.jackhuang.hmcl.ui.construct.ComponentList;
import org.jackhuang.hmcl.ui.construct.RipplerContainer;
import org.jackhuang.hmcl.ui.construct.SpinnerPane;
import org.jackhuang.hmcl.ui.construct.TwoLineListItem;
import org.jackhuang.hmcl.ui.wizard.Navigation; import org.jackhuang.hmcl.ui.wizard.Navigation;
import org.jackhuang.hmcl.ui.wizard.Refreshable; import org.jackhuang.hmcl.ui.wizard.Refreshable;
import org.jackhuang.hmcl.ui.wizard.WizardPage; import org.jackhuang.hmcl.ui.wizard.WizardPage;
@@ -65,8 +69,8 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static org.jackhuang.hmcl.ui.FXUtils.*; import static org.jackhuang.hmcl.ui.FXUtils.*;
import static org.jackhuang.hmcl.util.logging.Logger.LOG;
import static org.jackhuang.hmcl.util.i18n.I18n.i18n; import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
import static org.jackhuang.hmcl.util.logging.Logger.LOG;
public final class VersionsPage extends Control implements WizardPage, Refreshable { public final class VersionsPage extends Control implements WizardPage, Refreshable {
private final String gameVersion; private final String gameVersion;
@@ -172,7 +176,10 @@ public final class VersionsPage extends Control implements WizardPage, Refreshab
{ {
if ("game".equals(control.libraryId)) { if ("game".equals(control.libraryId)) {
JFXButton wikiButton = newToggleButton4(SVG.GLOBE_BOOK); JFXButton wikiButton = newToggleButton4(SVG.GLOBE_BOOK);
wikiButton.setOnAction(event -> onOpenWiki()); wikiButton.setOnAction(event -> {
onOpenWiki();
wikiButton.getScene().getRoot().requestFocus();
});
FXUtils.installFastTooltip(wikiButton, i18n("wiki.tooltip")); FXUtils.installFastTooltip(wikiButton, i18n("wiki.tooltip"));
actions.getChildren().add(wikiButton); actions.getChildren().add(wikiButton);
} }