I have a Java FX application in which I show a Popup that contains a text field. I intentionally keep this popup visible even when the user clicks away from it. This works fine except for one case:
When the user has focus on the text field in the Popup, then clicks on a separate application, and then clicks back onto the text field. The FX application does not regain focus from the OS. If the user types on the keyboard, the other application will still receive the keyboard input. To work around this, the user has to click on the main FX application window outside of the popup.
The strange thing is that, in debugging, I can see that the text field in the Popup is getting focus, but the OS does not show that the FX application is now in focus. Is there a way that I can force the OS to move focus to my application?
This occurs on Windows and Mac. I tested with jdk 8 update 45 and jdk 8 update 92.
I did a test with a minimum Popup:
static class TestPopup extends Popup {
TestPopup() {
content.add(new TextField("Hello"))
}
}
and I show it by calling:
new TestPopup().show(somePaneInMainWindow, 0, 0)
After some research I found that this is expected behavior.
Answer found here:
http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8123137
From the link:
This is the right behavior. All the JavaFX popup windows are
unfocusable, so they can receive input only if the owner window is
currently focused. Usually popups are set to auto hide, when the owner
gets unfocused, but this is not the case in this test, so the popup
just stays around.
Related
I am new to QtWebAssembly. I am trying to build a simple app "Hello World" as a starting point to understand. The app contains a push button and when it is clicked a qlabel with text is set to visible using slot.
When i build and run the app, my firefox browser runs and opens a page as shown below:
ex-app
But, i am not able to access the button or the button is not working.
I am working on OS - Ubuntu 20.x
I need an helping hand on what i am missing so that when I press the button the qlabel should be visible.
Thank you.
Bhimesh G K
The strangest behaviour occured and I can't handle it myself.
I have ASP .NET MVC application with Jqgrid version 5.1.0. Everything works fine, beside one dialog window.
In my grid I use default deletion method. There is delete button defined by $(tableHtmlId).navGrid( ... ) function. After clicking delete button, confirmation dialog window appears. This dialog has misplaced cancel button (the one on top-right corner), as shown on following screen:
I thought about editing css styles, so I hit the console button, and as soon as develpers tool window appeard, look what happened:
Everything look fine. However, when I put cursor over cancel button, it goes back to wrong:
This behaviour occurs on Chrome, Firefox and IE. This bug is too atomic for me to solve. Please help. :)
Am running a JavaFx application on mac OSX 10.10
I am minimizing the window using:
primaryStage.setIconified(true);
And then restoring the window by using:
primaryStage.setIconified(false);
primaryStage.requestFocus();
myTextBoxOnStage.requestFocus();
There are two different scenarios:
If the JavaFx window is hidden, and I DON'T click on any other
application, then the JavaFx window is restored using the method
above, then all is good. The JavaFx window is displayed and the component myTextBoxOnStage has focus.
If the JavaFx window is hidden, then I DO click on
another application, then the JavaFx window is restored, then although my JavaFx application comes to the front, the previous application that I clicked on remains with the focus.
It is scenario #2 that I am trying to solve.
To check whether the JavaFx window was getting focus, but then losing it somehow, I installed a listener:
primaryStage.focusedProperty().addListener((ov, t, t1) -> {
System.out.println(t1 ? "IN FOCUS!": "NOT IN FOCUS");
});
However in scenario #2, the JavaFx window never gets focus.
Any help would be appreciated.
I am developing a touch application for Windows 7 with Qt/QML. The end-user-device has Windows 7's native touch behavior, i.e.: When touching the screen, a point appears on the last-touched-point, and when ending the physical touch, Windows puts that point on the now-touched point and runs in the on-clicked-Event.
Compared to the behavior one knows from standard Windows mouse-usage, this leads to a different behavior as soon as it comes to e.g. clicking some button: A mouse user will expect that the button changes color to the pressed-down-color when mouse button goes down, while the color changes to the default color again when the mouse button goes up.
In my application, I want to have a customized way of touch feedback: What is currently being touched should be marked using changed colors of buttons, imitating a "mouse goes down" when the actual physical touch begins and imitating a "mouse goes up" when the actual physical touch ends.
My application will run fullscreen, so an actual possibility would be to change the system's behavior on application start and change it back to default on applications end.
Such a behavior would effectively be the same as the standard behavior on e.g. all Android devices I know.
I searched through all the MouseArea and MultiPointTouchArea elements, trying to find a way to just make the click-reaction behavior different to the standard behavior. However I did not even find a way to capture the begin of the actual touch ... All the things which I want to happen at the begin of the touch actually happen when the touching ends.
Edit:
It does not matter if I use a QML button or a mousearea plus the MouseArea.pressed property: Nothing will be "pressed" before the finger leaves the touch and the onClicked() even is called.
Possibly related:
Adobe AIR: touch screen doesn't trigger mouse down event correctly - but I did not find a way to access the functions like Multitouch.inputMode (which are mentioned in the first reply) from a native Qt application.
How can I achieve the described behavior for my application?
The solution for this issue is to disable "Press and Hold" for the application. This is what can be done in a system-wide setting using ...
Control Panel -> Pen and Touch -> Touch -> Press and Hold -> Settings -> uncheck 'Enable press and hold for right-clicking'
The only solution I found to to this in native code can be found here:
http://msdn.microsoft.com/en-us/library/ms812373.aspx
I checked that this is at least still working for Windows 7. To get it working for QML, I searched for the QWindow* in QQmlApplicationEngine::rootObjects() and used its winId as a HWND. With that HWND, I called the TogglePressAndHold function from the link before app.exec().
I have an AIR application with a system tray icon. When clicked it shows and activates the app. This is working as expected when the app is hidden (docked), however if I select another application so my app is in the background clicking on the system tray icon does nothing.
Oddly I also have a contextual menu on the system tray icon, which has an option to restore, this calls the same event handler as ScreenMouseEvent.CLICK, yet works.
I expect it's something to do with the contextual menu changing the focus, perhaps it's a bug in how AIR works with the system tray, perhaps it's just something I'm missing. Would be good to know if that's the case.
Thanks in advance
Rob
//instead of just calling
activate();
//call
nativeApplication.activate()
//or even better
nativeApplication.activate(nativeWindow);
Update based on OP's input: if you have multiple windows open for the application, use:
nativeApplication.activate(nativeApplication.openedWindows[0]);
If you are not in the main WindowedApplication class, you can use the static property NativeApplication.nativeApplication to get a reference to the singleton object.
WindowedApplication.activate()
Activates the underlying NativeWindow (even if this application is not the active one).
NativeApplication.activate(window:NativeWindow = null)
Activates this application. If the operating system allows activation, then the specified window is activated and brought to the desktop foreground; that is, in front of the windows of other applications. (If the window parameter is null, then a visible window of this application is activated.)
livedocs is not clear on why this is happening. It says activate() activates the underlying native window - one would expect it to be brought to the front when it is activated, but that's not happening.