JavaFX8: Application in fullscreen mode doesn't show focus on elements - focus

I have the following problem: I would like to see which textfield or button is focused when I enter my multiscreen application in fullscreen mode. But for some reason, it is not showing the focus "glow" around for example a textfield. This is not a major problem, while it is focused the way I want it (requestFocus() does its job).
But it now gets annoying when I want to use AutoComplete TextField Completion from ControlsFX (How to implement AutoComplete TextField using ControlsFX), because the list is not shown in full screen mode.
I will clarify the situation with these screenshots:
How it is now in fullscreen mode:
How it should be (and how it is in non fullscreen):
To be clear: the problem doesn't only exist with AutoComplete TextField, but with every FXML element.
If I use the fullscreen mode from OSX itself, it works the proper way (It gives an error on the background). But I want the application to start in fullscreen mode.
This the code from my Main.java:
public class Main extends Application {
//Get the screenscontroller instance
octocash.GUI_Screens.ScreensController mainContainer = octocash.GUI_Screens.ScreensController.getInstance();
//Get the configuration instance
Configuration initApp = Configuration.getInstance();
//Create an object of Functions to establish a database connection
public static Functions databaseConnection = new Functions();
//Create a stage object to hold the primarystage
public static Stage primaryStage;
#Override
public void start(Stage stage) throws Exception {
primaryStage = stage; //set the primary stage
databaseConnection.DB_Connect(); //establish database connection
//Load the initial screen (lockscreen)
mainContainer.loadScreen(Configuration.lockScreen, Configuration.lockScreenFile);
mainContainer.setScreen(Configuration.lockScreen);
Group root = new Group(); //Create a group to hold all other screens
root.getChildren().addAll(mainContainer); //Add all Screenscontroller screens to the Group
Scene scene = new Scene(root); //set the group to the scene
stage.getIcons().add(new Image("file:src/octocash/images/octo_cash_logo.png")); //add a menubar icon
stage.setTitle("OctoCash Development"); //set the window name
stage.setScene(scene); //set the scene
stage.setFullScreen(true); //full screen without borders (no program menu bars)
stage.setFullScreenExitHint(""); //Don't show "Press ESC to exit full screen"
//stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); //DO NOT TURN ON UNLESS YOU CREATED ANOTHER METHOD TO EXIT THE PROGRAM
stage.show(); //show the application
}
/**
* #param args the command line arguments
*/
public static void main(String[] args) {
launch(args); // start the application
}
}
As you can see, I am using a ScreensController, which is basically a StackPane with all of the screens in it.
I hope the question is clear to you all.
Any help is greatly appreciated!

I figured out that this is an error in Java JDK 8u25. I have now updated to Java JDK 8u40, and this solves the problem. Also, I have tested the fullscreen focus on Windows and Linux, and there it also works. So if you are having the same problem, just update your JDK.

Related

Jetpack Compose back button press in automation test

What is the recommended way to trigger a back button press in a jetpack compose test (running on a real device)?
I'm trying:
#get:Rule()
val composeTestRule = createAndroidComposeRule(MyActivity::class.java)
#Test
fun test() {
// Here would be some setup code, assertions and navigating into a second screen
// Navigate back to previous screen
composeTestRule.onRoot().performKeyPress(KeyEvent(NativeKeyEvent(0, KeyEvent.KEYCODE_BACK)))
// continue...
}
But I get the error:
java.lang.IllegalStateException: KeyEvent can't be processed because this key input node is not active.
I don't have any special logic for the key presses / navigation and only use out-of-the box functionality of the navigation compose library.
I ended up using the ActivityScenarioRule:
composeTestRule.activityRule.scenario.onActivity { activity ->
activity.onBackPressedDispatcher.onBackPressed()
}
Not sure if this is the right way to do it but it works.
EDIT: As pointed out correctly by LN-12 you should be using the onBackPressedDispatcher to support API 33's predictive back gestures.
We can use below code to test device back button from composable screen
Espresso.pressBack()

GWT: Textbox doesn't show Cursor on Ipad

I am trying to implement a Textbox that can show fractions with GWT.
Therefor I have an Canvas were I can draw what I want and receive KeyEvents and MouseEvents.
But on Ipad (Safarie and Chrome) the software keyboard does not show, so I created an Composite and combined the Canvas with a Textbox witch gets the focus after each key or mouse Event on the Canvas.
But the softkeyboard does not show up every time so I tried a bit and can see, that the Textbox seems to get the focus (it gets a blue boarder) but does not always show the cursor.
This does not happen on my Notebook.
Is there any difference between being focused and showing the cursor?
I tried:
Setting the Cursor position
set the Text of the Textbox.
Any help would be appreciated,
Christoph
public void setFocus(boolean b) {
// if (hasFocus) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute () {
t.setFocus(b);
}
});
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute () {
box.setFocus(true);
box.setText("x");
box.setCursorPos(0);
// box.setVisible(false);
// box.setVisible(true);
}
});
// t.setFocus(b);
// box.setFocus(b);
// }
}
The iOS browsers don't allow the focus to be set programmatically unless directly in response to a user interaction (i.e. a touch). I believe the reason is to prevent websites bringing up the virtual keyboard for no reason.
The downside is that it clobbers setFocus() for websites that want to use it for legitimate reasons. You can't call setFocus() in a deferred command because that doesn't count as a direct response to the user interaction.
(To be more precise, you can call setFocus() in a deferred command, but it won't have the desired effect as you found out.)

Caliburn micro ShowDialog wont appear a second time

I am working on an application that has a splash screen and then a login screen before it pulls up the application. I am using Caliburn Micro to tie everything together but for some reason I am only able to get the Splash Screen to appear. Once the splash screen finishes loading, I call the secondWindow.ShowDialog(LogOnVM) and nothing happens. If I comment out the splash screen code, the the login screen does appear just fine. They just don't appear one after another.
I used Application.Windows.Count after the second ShowDialog gets called and it does show a count of 1. (It is 0 after the first dialog closes) So I know there is a form opening somewhere but I its not visible or something.
I have even tried creating a new instance of WindowManager but that did nothing either.
I have placed:
var cmWindowManager = IoC.Get<IWindowManager>();
var cmSplashScreenViewModel = IoC.Get<SplashScreenViewModel>();
cmWindowManager.ShowDialog(cmSplashScreenViewModel);
var cmLogOnViewModel = IoC.Get<LogOnViewModel>();
var result = cmWindowManager.ShowDialog(cmLogOnViewModel);
Here is how it is being setup. Should I create a second SimpleContainer
protected override void Configure()
{
LogManager.GetLog = x => new DebugLog(x);
sc = new SimpleContainer();
sc.Singleton<IWindowManager, WindowManager>();
sc.Singleton<IEventAggregator, EventAggregator>();
sc.Singleton<IFakeStartupTask, FakeStartupTask>();
sc.PerRequest<SplashScreenViewModel>();
sc.Singleton<IMessageBoxService, MessageBoxService>();
sc.PerRequest<LogOnViewModel>();
}
you need to call TryClose() in your cmSplashScreenViewModel
Below code can show twice the login window (after the 1st login closed)
var login = this.container.GetExportedValue<LoginViewModel>();
var windowManager = IoC.Get<IWindowManager>();
windowManager.ShowDialog(login);
windowManager.ShowDialog(login);

XNA loading/splash screen on game start

I'm trying to have a loading screen that pops up as soon as you run that executable that launches the game, whilst the game loads I want to display an image on the desktop much like how Gamemaker allows you to have a loading image.
I've had a brief look around and most people want an image to be shown whilst they load content which is not what I want, or perhaps it is... =P
My guess would be to set the game window borderless at the start, load the splash screen, draw it, then begin all the main loading (Specifically loading DirectInput through SlimDX takes a while). However would this support having a transparent/irregular shaped image? E.G if I wanted a borderless circle to be displayed whilst the game loads, would that be possible?
Thanks.
It's very simple. Just implement System.Threading and you're done.
Here's how it works, first add:
using System.Threading;
to the top of your class, then add the following things:
//the enum for state types
enum GameState
{
Loading,
StartMenu
}
//Init our gameState enum as variable
GameState gameState;
protected override void LoadContent()
{
gameState = GameState.Loading;
spriteBatch = new SpriteBatch(GraphicsDevice);
device = GraphicsDevice;
Window.Title = "Your Window";
//Other stuff that you had here before, now go in LoadGame()
loadingscreen = Content.Load<Texture2D>("loading");
Thread bgLoad = new Thread(new ThreadStart(LoadGame));
bgLoad.IsBackground = true;
bgLoad.Start();
}
public void LoadGame()
{
//Loading stuff here
gameState = GameState.StartMenu; //or GameState.Playing
}
and then put a loading texture in your Content Project
If I understand you correctly, you essentially want to have a window opened that is not full screen that also lacks the regular border and buttons that accompanies a window.
I can't test this but this should be a good start.
Here!
I would start by creating a bare bones Game1 class that can track an image and keep track of time for a timer.
Later you could add logic that actually tracks the loading of assets in the main program.
To start I'd just test it for a fixed time like 3 seconds.

Blackberry - problem with UiApplication.popScreen() on Blackberry OS 4.5

I have a application with a screen manager class that is causing me some problems.
The application makes requests to the server to perform searches and allows the user to view results.
The application has worked fine on all OS versions up to 4.5 where we are sudden having
problems viewing a screen under certain circumstances.
It occurs when the user has performed a search and they wait for the results.
While waiting for results, they press the trackball which displays a menu.
This is not needed to display the results, it just happened that the user decided to press it.
When the results come back from the server, the results screen should automatically be displayed. On OS 4.5, the code displays the results screen runs but then the application completely falls over. If the user doesn't press the trackball while waiting, the application works fine.
Looking at the logs, they show no exception being thrown and the only suspect line being
System data:VM:DPNAv=78,p
By adding in some more log lines I have discovered that the code is reaching the
UiApplication.getUiApplication().popScreen(screen);
line in the method hideScreen(Screen screen) but when called from hideCurrentScreen(). By adding in some more debugging I find that the active screen at this point is DefaultMenuScreen (as the menu button has been pressed)
So it seems the problem is that I am trying to pop one of my own screens from the display
stack when the DefaultMenuScreen one is the active one. I repeat that this code did work on OS previous to 4.5. By running the same code on the 8300 with OS 4.2.2 with the debugging statements, I can see that the same thing happens, the active screen is the DefaultScreen but removing my own screen does not cause the whole application to crash.
The one way round this I could see, was to change the hideCurrentScreen() to just remove the active screen but this does not seem like the correct way to do it.
Has anyone else had experience of this? Can anyone tell me why this is happening? What are we meant to do if we cannot remove our screens when a DefaultMenuScreen is the active one?
This occurs in both device and simulator for 8310 and 9700.
The screen manager code is as follows.
public class ScreenManager
{
private Hashtable screens;
private String currentScreenName;
public ScreenManager()
{
screens=new Hashtable();
}
/**
* Description of the Method
*
*#param sCardName Description of Parameter
*/
public boolean showScreen( String sScreenName )
{
boolean bSuccess=false;
if (sScreenName != null && sScreenName.length() > 0 )
{
MainScreen screen=(MainScreen)screens.get(sScreenName);
if (screen!=null)
{
// We have a new screen to display so pop the current screen off the stack
hideCurrentScreen();
// If the screen is on the stack then pop the screens until we get our target screen
// otherwise just push the screen onto the stack.
if (screen.isDisplayed())
{
Screen activeScreen=null;
synchronized(UiApplication.getEventLock())
{
activeScreen=UiApplication.getUiApplication().getActiveScreen();
}
while (screen!=activeScreen && activeScreen!=null)
{
activeScreen=hideScreen(activeScreen);
}
bSuccess=(screen==activeScreen);
}
else
{
synchronized(UiApplication.getEventLock())
{
UiApplication.getUiApplication().pushScreen(screen);
bSuccess=true;
}
}
}
}
if (bSuccess)
{
this.currentScreenName=sScreenName;
}
else
{
Logger.warning("ScreenManager: Failed to display screen ["+ sScreenName +"]");
}
return bSuccess;
}
private Screen hideCurrentScreen()
{
Screen activeScreen=null;
if(currentScreenName!=null)
{
MainScreen screen=(MainScreen)screens.get(currentScreenName);
activeScreen=hideScreen(screen);
}
return activeScreen;
}
private Screen hideScreen(Screen screen)
{
Screen activeScreen=null;
if (screen!=null && screen.isDisplayed())
{
Logger.finest("Hiding Screen ["+currentScreenName+"]");
synchronized(UiApplication.getEventLock())
{
UiApplication.getUiApplication().popScreen(screen);
activeScreen=UiApplication.getUiApplication().getActiveScreen();
}
Logger.finest("Hid Screen ["+currentScreenName+"]");
}
return activeScreen;
}
//Rest of code omitted
}
The only way round this I managed to find was what I mentioned in the question. When I want to remove the current screen. I need to check it is the same as the active screen. If it is not the same then I just remove the active screen until I reach the screen I am looking for. This would only happen if a menu or pop up was displayed. Also, I need to add checks to my custom pop-up code to make sure it does not try and remove a screen that has already been removed.
It seems a bit messy but could not find any other alternatives.
The way we pop screens in our app is to explicitly pop the screen you want off the stack, as opposed to just the top-most screen. This either requires keeping track of which screens you have on the stack, or some code to iterate through the screens on the stack and search for the particular screen you want to pop off.

Resources