|
36 | 36 | import java.util.List;
|
37 | 37 | import java.util.stream.Stream;
|
38 | 38 |
|
39 |
| -// TODO: make the search bar work |
40 | 39 | // TODO: wrap options within groups in two columns
|
41 | 40 | // TODO: make the mod config headers interactive: only show one mod's pages at a time, click on a mod header to open that mod's first settings page and close the previous mod's page list
|
42 | 41 | // TODO: change the scroll bar colors to make it look better against a lighter gray background
|
@@ -266,8 +265,7 @@ private void undoChanges() {
|
266 | 265 | }
|
267 | 266 |
|
268 | 267 | private void openDonationPage() {
|
269 |
| - Util.getPlatform() |
270 |
| - .openUri("https://caffeinemc.net/donate"); |
| 268 | + Util.getPlatform().openUri("https://caffeinemc.net/donate"); |
271 | 269 | }
|
272 | 270 |
|
273 | 271 | @Override
|
@@ -302,7 +300,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
302 | 300 | return true;
|
303 | 301 | }
|
304 | 302 |
|
305 |
| - // TODO: switching between the search and the regular mode breaks the keyboard focus |
| 303 | + // this ensures the right element is focused when the search bar is clicked |
306 | 304 | if (this.getFocused() == this.pageList && this.controlList == this.searchWidget ||
|
307 | 305 | this.getFocused() == this.searchWidget && this.controlList == this.optionList) {
|
308 | 306 | this.setFocused(this.controlList);
|
@@ -402,13 +400,23 @@ private void startSearch(@Nullable SearchWidget old) {
|
402 | 400 | this.searchWidget = new SearchWidget(this, this::closeSearch, old, new Dim2i(0, 0, Layout.PAGE_LIST_WIDTH + Layout.INNER_MARGIN + Layout.OPTION_WIDTH, this.height));
|
403 | 401 | this.addRenderableWidget(this.searchWidget);
|
404 | 402 |
|
| 403 | + // remove focus from page list even if it doesn't get destroyed so that it isn't focused when the search is closed |
| 404 | + this.pageList.setFocused(null); |
| 405 | + |
405 | 406 | this.removeWidget(this.pageList);
|
406 | 407 | this.removeWidget(this.optionList);
|
407 | 408 |
|
| 409 | + // set the search widget to be the focused element in search mode |
408 | 410 | this.controlList = this.searchWidget;
|
| 411 | + this.setFocused(this.searchWidget); |
409 | 412 | }
|
410 | 413 |
|
411 | 414 | private void closeSearch() {
|
| 415 | + // remove focus from the search widget that's getting removed |
| 416 | + if (this.getFocused() == this.searchWidget) { |
| 417 | + this.clearFocus(); |
| 418 | + } |
| 419 | + |
412 | 420 | this.removeWidget(this.searchWidget);
|
413 | 421 | this.searchWidget = null;
|
414 | 422 |
|
|
0 commit comments