Trying to enable mouse interaction with the SVGDom via a JSVGCanvas instance. I've seen the advice to simply add an EventListener to a specific node, such as
myNode.addEventListener("mouseover", myListener, true);
I have done that, but I am not getting any events fired. I've also tried it with the "click" event. Nothing seems to be working.
I am able to render SVG documents (even fairly complex ones), via the setSVGDocument(doc) method. I've also called:
setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC)
all over the place, especially before calling setSVGDocument. I'm not getting any sort of mouse feedback via the rendered SVG. Is there a way of testing that the interactions are happening at a low level? Does one have to register one of those mouse Interactors to enable mouse-actions? Also, does the SVGDOMImplementation version matter? I'm not using the SVG12DOMImplemenation, but the earlier/standard one.
Advice very appreciated. Thanks.
Related
In a fairly complicated codebase, there is functionality both to
(a) drag objects places, implemented with DragGestureRecognizer,
(b) and the ability to drag boxes around things to select them, implemented via e.g. mousePressed() listeners.
Normally they behave "correctly".
However there are some objects which are marked immovable, and when the user begins a mouse gesture on top of one of them, the DragGestureRecognizer is finding it, and apparently consuming the mouse event.
What I'd like to be able to do is e.g. add something to my DragGestureRecognizer to say "oh look, we found an immovable object, let's not have this be a drag after all", and allow the dragging-a-box-around-things to take control.
I realize I'm not providing code because there is way too much to provide, but short of disabling the DragGestureRecognizer entirely (bad), I haven't found a way to get it to (selectively) turn loose of mouse events. Any help much appreciated!
I'm developing a plugin for IntelliJ IDEA, which obviously uses Swing.
For a feature I have introduced I'd like to stop a JPopupMenu which uses JCheckBoxMenuItems from losing focus and closing.
You can see it in action.
I've debugged the code, but I couldn't figure out how to do it, also being I'm not that into Swing.
Could you maybe point me to useful listeners/blocks of code/ways to prevent this?
If you want to see code, the IntelliJ classes are
ActionPopupMenuImpl.MyMenu
ActionMenuItem
Edit: a better way need to be found as the uiRefreshed event isn't always called at the right time.
Just coordinate your code in a good way ;)
The Swing mechanism in IDEA is too complicated, and maybe it's better to not touch it. Just know that the mouse events are handled by a special listener and then redirected to Component(s).
That said, having an hold on the menu ActionButton. You can listen for the Lookup's uiRefreshed event and programmatically:
myMenuButton.click()
That's all.
You need to call it after the UI has been refreshed because the LookupUi might have changed in dimension or location.
I'm using the dispatchGesture API from Android accessibility.
I've added an overlay to the screen and I'm looking for a way to dispatchGesture behind the overlay (the overlay is what's intercepting the original gesture) since otherwise the gesture is dispatched on my OverlayView and don't play back in the app.
Is there any way to do this with the accessibility API?
For context - I want to be able to help people record actions in Android and replay them for accessibility.
Alas, there is no way to do this generally. A touchable overlay will capture all touches, as you're observing. It's not possible to do general-purpose filtering of touch events.
You've probably already thought of this, but if you're playing back pre-recorded gestures, you can remove your overlay before you dispatch them.
The general purpose filtering API doesn't exist because it's very difficult to filter touch events outside the system process without introducing serious jank.
You must use FLAG_NOT_TOUCHABLE params flag for your view and then dispatch your click.
At times, certain UI elements that have a hover style will not render at all and a white box is left in it's place. This only happens after I resize the application window and when the UI element is completely outside of the original bounds of the application window. The button shown in the images below also does not immediately render correctly after removing the mouse pointer from the hover position, so the issue likely would occur whenever the button needs to be repainted.
"Device Logging" button is being hovered by the mouse, before resizing the window.
After resizing the window. Both the "Device Logging" and "Misc Tests" buttons are 100% outside of the original bounds of the window. The "Cloud Server Migration" button however is still rendering correctly.
I have set styles, but removing them has no effect. The issue only seems to appear when there is other processing taking place, such as running the firmware update function. That tells me that there may be something taking up UI time, but I would have expected that to affect every UI element, not just certain ones.
One other note, the UI was converted from Swing to JavaFX, so all of the threading did not include the use of Task or Platform.runlater(). I have since made sure all UI updates are using Platform.runlater(), but I have not yet converted all of the original threads that don't update the UI to Tasks. Below I am including the framework of running a firmware update.
Edit: Was able to reproduce the issue without starting a firmware update, so I don't think it has anything to do with processing blocking UI rendering. The issue occurred only after using some of the UI. As such I removed the code that was posted above. This leads me to believe it has more to do with the actual layout of the UI.
I believe I have figured out the issue. I use a ListView to hold an Object and a cellfactory to render each of the cells with a custom UI. When populating the list with items, additional threads are spawned to retrieve information for each Object within the cell. The variables associated with the Object are bound to a view property within the custom UI. I was not using Platform.runlater() to update these properties with the new information. After updating the sets to runlater, the issue appears to have been fixed.
It is bad practice to do big jobs on the UI thread as if you do, those big jobs will cause the program to hang (not accept user input or render any new data) until that job is finished.
I am looking to add a widget to our code base that will indicate to developers when they have committed this taboo. My idea, and one I've seen on a number of other applications, is to have some component that is constantly moving at a constant speed, such as a bar that is constantly twirling on the screen. With such a tool, if a developer is working and accidentally does something that is more computationally difficult than he expected on the UI thread, this spinning bar will become choppy, indicating to him, when he does functional testing, that he needs to implement mechanisms that will cause this job to be executed elsewhere.
One odd requirement on this code is that it should be completely non-existent in production builds, and only present in dev builds, since it is a widget not for users, but for developers.
I jumped into the Canvas objects and wrote up a quick component that simply spins a teal bar. The idea is that if a big job is dumped on the UI thread, the bar will stop spinning (since the FX job queue wont continue dispatching) and the bar will jump forward, rather than rotate smoothly (as it does when the program is at rest).
Below is a screen-shot of this first implementation:
(notice the teal bars, which, if you saw our application running, would be rotating slowly but steadily --hopefully anyways)
The issue here (as you might notice) is that our layout's been screwed up. This is because I'm modifying the scene graph from this:
Scene
RootComponent
Content
to
Scene
obnoxiousPane
Canvas
Spinner(s)
RootComponent
Content
Modifying the scene graph in such a way has things like preferred height, mouse events and (presumably) any number of other events getting dispatched to the spinners rather than the content components.
Of course, when we go to production, I would like to have the original scene graph in the version that we give to our users.
So my question is this: How should I go about correcting these problems?
I could go after each of them individually as they come up, writing a lot of custom code to do things like
obnoxiousPane.prefHeightProperty().bind(content.prefHeightProperty)
obnoxiousPane.prefWidthProperty()//...
spinner.setMouseTransparent(true)
spinner.setOtherEventsIProbablyCantEnumerateWithoutSeriousResearchTransparent(true)
Or I could try to go after this problem with reflection, attempting to bind every property in the content pane to the corresponding obnoxiousPane property, but this seems like a bug breeding ground.
Or... what? I'm hoping there's some LightWeight component or ImNotReallyHereProperty that I can leverage to add this development aid.
Thanks for any help!
Your approach seems fundamentally flawed. You shouldn't be stalling the JavaFX application thread.
Instead you should have a concurrent process and update the UI as appropriate as the process starts, progresses and completes.
See this java2s sample for using the JavaFX concurrency and progress indicator facilities for an example of such an alternate approach.
If you want to disable some portion of the UI for a time, nodes have a disabled property which you can set. You can use CSS to style a disabled node so the user has some indication that the thing hasn't just hung and is deliberately disabled.