mirror of
https://github.com/badvision/jace.git
synced 2024-11-30 23:49:52 +00:00
Reset keyboard state when window is deactivated/reactivated
This commit is contained in:
parent
732f4768a6
commit
ca6a831020
@ -58,7 +58,7 @@ public class JaceApplication extends Application {
|
||||
while (Emulator.computer.getVideo() == null || Emulator.computer.getVideo().getFrameBuffer() == null) {
|
||||
Thread.yield();
|
||||
}
|
||||
controller.connectComputer(Emulator.computer);
|
||||
controller.connectComputer(Emulator.computer, primaryStage);
|
||||
bootWatchdog();
|
||||
});
|
||||
primaryStage.setOnCloseRequest(event -> {
|
||||
|
@ -10,6 +10,7 @@ import com.sun.glass.ui.Application;
|
||||
import jace.cheat.MetaCheat;
|
||||
import jace.core.Card;
|
||||
import jace.core.Computer;
|
||||
import jace.core.Keyboard;
|
||||
import jace.library.MediaCache;
|
||||
import jace.library.MediaConsumer;
|
||||
import jace.library.MediaConsumerParent;
|
||||
@ -43,6 +44,7 @@ import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -79,10 +81,11 @@ public class JaceUIController {
|
||||
rootPane.setOnDragExited(this::processDragExitedEvent);
|
||||
}
|
||||
|
||||
public void connectComputer(Computer computer) {
|
||||
public void connectComputer(Computer computer, Stage primaryStage) {
|
||||
this.computer = computer;
|
||||
appleScreen.setImage(computer.getVideo().getFrameBuffer());
|
||||
EventHandler<KeyEvent> keyboardHandler = computer.getKeyboard().getListener();
|
||||
primaryStage.setOnShowing(evt->computer.getKeyboard().resetState());
|
||||
rootPane.setFocusTraversable(true);
|
||||
rootPane.setOnKeyPressed(keyboardHandler);
|
||||
rootPane.setOnKeyReleased(keyboardHandler);
|
||||
|
@ -39,6 +39,7 @@ import java.util.logging.Logger;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.stage.WindowEvent;
|
||||
|
||||
/**
|
||||
* Keyboard manages all keyboard-related activities. For now, all hotkeys are
|
||||
@ -50,6 +51,12 @@ import javafx.scene.input.KeyEvent;
|
||||
*/
|
||||
public class Keyboard implements Reconfigurable {
|
||||
|
||||
public void resetState() {
|
||||
clearStrobe();
|
||||
openApple(false);
|
||||
solidApple(false);
|
||||
}
|
||||
|
||||
private Computer computer;
|
||||
|
||||
public Keyboard(Computer computer) {
|
||||
|
Loading…
Reference in New Issue
Block a user