Skip to content

Commit 48f3bfd

Browse files
committed
Focusing Alert log cell when input alert log index using enter key
1 parent 8aa9ea2 commit 48f3bfd

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/main/java/root/javafx/Controller/AlertLogMonitoringMenuController.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@
1414

1515
import javafx.application.Platform;
1616
import javafx.event.ActionEvent;
17+
import javafx.event.Event;
18+
import javafx.event.EventHandler;
1719
import javafx.fxml.FXML;
1820
import javafx.fxml.Initializable;
1921
import javafx.scene.control.Alert.AlertType;
2022
import javafx.scene.control.DatePicker;
2123
import javafx.scene.control.TextField;
24+
import javafx.scene.input.KeyCode;
25+
import javafx.scene.input.KeyEvent;
2226
import javafx.scene.layout.AnchorPane;
2327
import javafx.scene.layout.StackPane;
2428
import lombok.extern.slf4j.Slf4j;
@@ -169,6 +173,15 @@ private void initAlertLogMonitoringElements() {
169173

170174
// AlertLog Navigator
171175
navigatorTF.setTextFormatter(new NumberTextFormatter());
176+
navigatorTF.setOnKeyReleased(new EventHandler<KeyEvent>() {
177+
@Override
178+
public void handle(KeyEvent e) {
179+
if (e.getCode().equals(KeyCode.ENTER)) {
180+
focusAlertLog(e);
181+
e.consume();
182+
}
183+
}
184+
});
172185

173186
// Set view visible
174187
mainNodataAP.setVisible(true);
@@ -247,7 +260,7 @@ public void monitoringAlertLog(ActionEvent e) throws Exception {
247260
summaryNodataAP.toBack();
248261
}
249262

250-
public void focusAlertLog(ActionEvent e) {
263+
public void focusAlertLog(Event e) {
251264
String input = navigatorTF.getText();
252265
if (!validateAlertLogNavigatorInput(input)) {
253266
return;

0 commit comments

Comments
 (0)