Improve completing the future in windows
This commit is contained in:
@@ -15,8 +15,6 @@ public interface Window extends Widget {
|
|||||||
|
|
||||||
CompletableFuture<Window> getFuture();
|
CompletableFuture<Window> getFuture();
|
||||||
|
|
||||||
void setFuture(CompletableFuture<Window> future);
|
|
||||||
|
|
||||||
default void onOpen(WindowManager manager, Object[] args) {
|
default void onOpen(WindowManager manager, Object[] args) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,8 +63,6 @@ public final class WindowManager extends BaseWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<Window> open(@NonNull Window window, Object... args) {
|
public CompletableFuture<Window> open(@NonNull Window window, Object... args) {
|
||||||
window.setFuture(new CompletableFuture<>());
|
|
||||||
|
|
||||||
if (windows.isEmpty()) {
|
if (windows.isEmpty()) {
|
||||||
input.addKeyEventHandler(this::forwardKeyEventToTopWindow);
|
input.addKeyEventHandler(this::forwardKeyEventToTopWindow);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import com.bartlomiejpluta.base.api.gui.*;
|
|||||||
import com.bartlomiejpluta.base.api.screen.Screen;
|
import com.bartlomiejpluta.base.api.screen.Screen;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@@ -24,7 +23,6 @@ public abstract class BaseWindow extends BaseWidget implements Window {
|
|||||||
protected WindowPosition windowPosition = WindowPosition.CENTER;
|
protected WindowPosition windowPosition = WindowPosition.CENTER;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
|
||||||
protected CompletableFuture<Window> future;
|
protected CompletableFuture<Window> future;
|
||||||
|
|
||||||
protected BaseWindow(Context context, GUI gui, Map<String, Component> refs) {
|
protected BaseWindow(Context context, GUI gui, Map<String, Component> refs) {
|
||||||
@@ -104,6 +102,7 @@ public abstract class BaseWindow extends BaseWidget implements Window {
|
|||||||
@Override
|
@Override
|
||||||
public void onOpen(WindowManager manager, Object[] args) {
|
public void onOpen(WindowManager manager, Object[] args) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
|
this.future = new CompletableFuture<>();
|
||||||
content.focus();
|
content.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user