Пример #1
0
  private void initShortcutsPanel() {
    WidgetList<KeyBinder.ShortcutWidget> list =
        shortcuts.add(
            new WidgetList<KeyBinder.ShortcutWidget>(new Coord(300, 24), 16) {
              @Override
              public boolean mousedown(Coord c0, int button) {
                boolean result = super.mousedown(c0, button);
                KeyBinder.ShortcutWidget item = itemat(c0);
                if (item != null) {
                  c0 = c0.add(0, sb.val * itemsz.y);
                  item.mousedown(c0.sub(item.parentpos(this)), button);
                }
                return result;
              }

              @Override
              public Object tooltip(Coord c0, Widget prev) {
                KeyBinder.ShortcutWidget item = itemat(c0);
                if (item != null) {
                  c0 = c0.add(0, sb.val * itemsz.y);
                  return item.tooltip(c0, prev);
                }
                return super.tooltip(c, prev);
              }
            });
    list.canselect = false;
    KeyBinder.makeWidgets(
            () -> {
              for (int i = 0; i < list.listitems(); i++) {
                list.listitem(i).update();
              }
              return null;
            })
        .forEach(list::additem);
    shortcuts.pack();
    shortcuts.add(
        new PButton(200, "Back", 27, main), shortcuts.sz.x / 2 - 100, shortcuts.sz.y + 35);
    shortcuts.pack();
  }