Make Catalog browsers focusable with shortcuts

- Category and scenario list views can now be focused with
  ctrl+a/ctrl+s.
- Bind all keys with ctrl modifier
- Add "shortcut" concept to views which currently hooks to
  hot keys.
- In a catalog app by using a "shortcut" then takes the key
  event as a hot key, as it consumes resulting behaviour
  is to focus.
- Move view initInternal away from constructor call to
  require user to call init() which is not in a
  View interface
- Relates #826
This commit is contained in:
Janne Valkealahti
2023-11-12 16:43:11 +00:00
parent a9b1675595
commit 2d29050c34
10 changed files with 53 additions and 7 deletions

View File

@@ -207,11 +207,12 @@ public class Catalog {
private ListView<String> buildCategorySelector() {
ListView<String> categories = new ListView<>();
categories.shortcut(Key.a | KeyMask.CtrlMask, () -> {});
ui.configure(categories);
List<String> items = List.copyOf(categoryMap.keySet());
categories.setItems(items);
categories.setTitle("Categories");
categories.setTitle("Categories (CTRL+A)");
categories.setFocusedTitleStyle(ScreenItem.STYLE_BOLD);
categories.setShowBorder(true);
return categories;
@@ -242,8 +243,9 @@ public class Catalog {
private ListView<ScenarioData> buildScenarioSelector() {
ListView<ScenarioData> scenarios = new ListView<>();
scenarios.shortcut(Key.s | KeyMask.CtrlMask, () -> {});
ui.configure(scenarios);
scenarios.setTitle("Scenarios");
scenarios.setTitle("Scenarios (CTRL+S)");
scenarios.setFocusedTitleStyle(ScreenItem.STYLE_BOLD);
scenarios.setShowBorder(true);
scenarios.setCellFactory((list, item) -> new ScenarioListCell(item));