Skip to content

Commit 9a3598c

Browse files
author
Jan Schraff
committed
added hack to fix strg + a Bug
1 parent 64c01c8 commit 9a3598c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/main/java/de/doubleslash/keeptime/view/ManageWorkController.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import org.slf4j.Logger;
2525
import org.slf4j.LoggerFactory;
2626

27+
import com.sun.javafx.scene.control.skin.ComboBoxListViewSkin;
28+
2729
import de.doubleslash.keeptime.common.ColorHelper;
2830
import de.doubleslash.keeptime.common.StyleUtils;
2931
import de.doubleslash.keeptime.model.Model;
@@ -38,9 +40,12 @@
3840
import javafx.scene.control.ComboBox;
3941
import javafx.scene.control.DatePicker;
4042
import javafx.scene.control.ListCell;
43+
import javafx.scene.control.ListView;
4144
import javafx.scene.control.Spinner;
4245
import javafx.scene.control.SpinnerValueFactory;
4346
import javafx.scene.control.TextArea;
47+
import javafx.scene.input.KeyCode;
48+
import javafx.scene.input.KeyEvent;
4449
import javafx.scene.layout.GridPane;
4550
import javafx.scene.paint.Color;
4651
import javafx.util.StringConverter;
@@ -240,6 +245,19 @@ public void changed(final ObservableValue<? extends String> observable, final St
240245

241246
});
242247

248+
// strg+a Behaviour bug hack
249+
// https://stackoverflow.com/questions/51943654/javafx-combobox-make-control-a-select-all-in-text-box-while-dropdown-is-visi
250+
projectComboBox.setOnShown(e -> {
251+
final ComboBoxListViewSkin<?> skin = (ComboBoxListViewSkin<?>) projectComboBox.getSkin();
252+
final ListView<?> list = (ListView<?>) skin.getPopupContent();
253+
list.addEventFilter(KeyEvent.KEY_PRESSED, keyEvent -> {
254+
if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.A) {
255+
projectComboBox.getEditor().selectAll();
256+
}
257+
});
258+
projectComboBox.setOnShown(null);
259+
});
260+
243261
}
244262

245263
public void initializeWith(final Work work) {

0 commit comments

Comments
 (0)