I'd like to disable focus system in a JavaFX application. That means no focus traversal, no control could receive focus, so it would never have corresponding graphic decoration and would never receive keyboard events. All keyboard events should be caught and processed by the root node (or stage).
What should I extend/rewrite to disable focus system?
To process all keyboard events in the root node, do
root.addEventFilter(KeyEvent.ANY, e -> {
// handle keyboard event...
e.consume();
});
Related
There are recipes on how to change focus on mouse move or client change.
But what I want, is to prevent any window from stealing focus. E.g. I open a new terminal via the default meta-Enter shortcut, and when it opens it immediately steals focus. Is there any way to prevent it?
Yes, it's possible. Focus events can happen in many ways. In the case of the new clients, just comment the focus line in your rules.
For the focus follow mouse, remove the client.focus = c in the mouse::enter section of rc.lua
For specific clients, you can add focus filters:
https://awesomewm.org/apidoc/libraries/awful.ewmh.html#add_activate_filter
For the deepest and most advanced focus control, you can disconnect the default focus handler (awful.ewmh.activate) from the request::activate (Awesome 4.0+) signal and implement your own. In that case, you will have absolute control over every focus events.
I have a qwidget derived control.
I need to capture mouse wheel events outside the control / window if the mouse is button is pressed inside the control then the mouse is moved outside.
Mouse move events are captured wheel events are not.
Qt calls capturemouse when button is pressed.
I don't mind doing specific conditional statements for this if necessary.
I am testing on Ubuntu 16.04 and intend to cross compile for windows and possibly Mac,
Set widget focus policy to Qt::WheelFocus.
setFocusPolicy(Qt::WheelFocus);
Is there any way to handle, mouse click, for example on disabled element? My task is to have disabled list and make it enabled after double click on it.
A disabled Node does not receive mouse or key events.
See the official documentation.
You could wrap the node into another node and handle the mouse events there in case the child node is disabled.
I´am trying to create my own custom list component in a Flex mobile Project which fires an Event when the user touches a listitem and holds the finger down for a given time.
Some kind of "longTouch"-Event like its implemented on native android listitems to edit the entry for example.
I tried to listen for the MOUSE_DOWN Event to start a timer and dispatch an event when the timer finished. But this approach failed because i cant get the listitem that was pressed by the user because the List component updates the "selectedItem"-property only after the user lifts his finger from the list.
thanks in advance
Andre Uschmann
There is no longTouch (or longPress) event exposed through the Flash Player Native APIs.
One option is to roll your own using TOUCH_BEGIN, TOUCH_END, and a timer.
Basically:
When user starts the touch, start the timer.
When the touch_End event fires; check the timer to see how long it has been running using currentCount. If it is long enough to be considered a "long touch", then dispatch your custom longPress event. If not; then stop the timer and ignore.
This could all happen inside the renderer; so you'd know exactly what item was pressed.
I expect this would be more solid than using mouse events, which seem to be inconsistent on touch based devices
I was making an application with AIR + Flex.
One Feature is like:
When Alt key is down, the mouse cursor changes to B,
When Alt key is up, the mouse cursor restores to A.
But the problem is that everytime a release Alt key, the mouse cursor will change back to system default (Arrow shape), and seems like the focus is on somewhere outside the stage.
That reminds me that, when Alt was pressed in a ordinary window, the menu-bar will be focused.
How can I stop this default behavior ?
p.s. I have tried the following ways and doesn`t work:
1) listen to stage's KEY_DOWN/ KEY_UP event, and add event.stopImmediatePropagation() in the event handlers
2) listen to stage's KEY_DOWN/ KEY_UP event, and add event.preventDefault() in the event handlers
3) listen to stage's KEY_DOWN/ KEY_UP event, and add this.setFocus() in the event handlers. And callLater(this.setFocus) doesn't work too.
On win impossible. But U can write shell/bash script for activating your app and run it from AIR. See NativeProcess class.
Listen to deactivate event
And then do activate