mirror of
https://github.com/aNNiMON/HotaruFX.git
synced 2024-09-19 14:14:21 +03:00
Links now clickable
This commit is contained in:
parent
10c0034d64
commit
ee1c00b92c
@ -1,5 +1,6 @@
|
||||
package com.annimon.hotarufx;
|
||||
|
||||
import com.annimon.hotarufx.ui.ClickableHyperLink;
|
||||
import com.annimon.hotarufx.ui.controller.EditorController;
|
||||
import java.io.IOException;
|
||||
import javafx.application.Application;
|
||||
@ -14,6 +15,7 @@ public class Main extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
ClickableHyperLink.setHostServices(getHostServices());
|
||||
primaryStage.setTitle("HotaruFX");
|
||||
try {
|
||||
val loader = new FXMLLoader(getClass().getResource("/fxml/Editor.fxml"));
|
||||
|
@ -0,0 +1,38 @@
|
||||
package com.annimon.hotarufx.ui;
|
||||
|
||||
import java.util.Optional;
|
||||
import javafx.application.HostServices;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Hyperlink;
|
||||
|
||||
public class ClickableHyperLink extends Hyperlink {
|
||||
|
||||
private static HostServices hostServices;
|
||||
|
||||
public static void setHostServices(HostServices hostServices) {
|
||||
// Please, forgive me this approach
|
||||
// it saved me a lot of time
|
||||
ClickableHyperLink.hostServices = hostServices;
|
||||
}
|
||||
|
||||
public ClickableHyperLink() {
|
||||
init();
|
||||
}
|
||||
|
||||
public ClickableHyperLink(String text) {
|
||||
super(text);
|
||||
init();
|
||||
}
|
||||
|
||||
public ClickableHyperLink(String text, Node graphic) {
|
||||
super(text, graphic);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setOnAction(e -> Optional
|
||||
.ofNullable(hostServices)
|
||||
.ifPresent(s -> s.showDocument(getText()))
|
||||
);
|
||||
}
|
||||
}
|
@ -4,8 +4,8 @@
|
||||
<?import javafx.scene.text.TextFlow?>
|
||||
<?import com.annimon.hotarufx.ui.LineText?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
<?import javafx.scene.control.Hyperlink?>
|
||||
<?import com.annimon.hotarufx.ui.FontAwesomeIcon?>
|
||||
<?import com.annimon.hotarufx.ui.ClickableHyperLink?>
|
||||
<ScrollPane xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1"
|
||||
prefWidth="400.0" prefHeight="300.0"
|
||||
minWidth="NaN" minHeight="NaN"
|
||||
@ -25,10 +25,10 @@
|
||||
|
||||
<LineText />
|
||||
<FontAwesomeIcon icon="github"/>
|
||||
<Hyperlink>https://github.com/aNNiMON/HotaruFX</Hyperlink>
|
||||
<ClickableHyperLink>https://github.com/aNNiMON/HotaruFX</ClickableHyperLink>
|
||||
<LineText />
|
||||
<FontAwesomeIcon icon="globe"/>
|
||||
<Hyperlink>https://annimon.com/</Hyperlink>
|
||||
<ClickableHyperLink>https://annimon.com/</ClickableHyperLink>
|
||||
<LineText />
|
||||
|
||||
<LineText />
|
||||
@ -44,7 +44,7 @@
|
||||
<FontAwesomeIcon styleClass="h3" icon="font-awesome" />
|
||||
<LineText styleClass="h3" content=" Font Awesome" />
|
||||
<LineText content="by Dave Gandy" />
|
||||
<Hyperlink>http://fontawesome.io</Hyperlink>
|
||||
<ClickableHyperLink>http://fontawesome.io</ClickableHyperLink>
|
||||
<LineText />
|
||||
|
||||
<LineText styleClass="h3" />
|
||||
|
Loading…
Reference in New Issue
Block a user