I have a issue with Vaadin. It seems as the layout click event listener consumes my right clicks as well as left clicks.
I have a layout with some components inside, and when I try to right click for inspecting my elements, nothing happens in the browser since the event is consumed by the code.
Is there a way to prevent it from capturing the right mouse click? Thanks! Checking what was pushed inside the event does not affect the behaviour.. My listener;
this.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
public void layoutClick(LayoutEvents.LayoutClickEvent event) {
System.out.println("clicked.." + getSuit());
}});
Seems the answer is you can't. See: https://vaadin.com/forum/#!/thread/696409/701753
Now admittedly that is an old answer, but I just tried with vaadin7 and seems to me the behaviour hasn't changed. So you are left with extending the client side if you want to change the behaviour: https://vaadin.com/book/-/page/gwt.html
If you want to inspect specific element you can do:
In Google Chrome:
open Developer Tools (F12),
click on button "Select an element in the page to inspect it." (Magnifier icon on top left),
inspect your element.
Related
I am trying to create a tab system, with similar function to tabs in Chrome, where there is a cross on each tab to close it, like this:
With JavaFX, I can get close, by setting the tabpane closing policy to ALL_TABS. Unfortunately this means my new tab button (also a tab iself) can be closed:
I am aware of the SELECTED_TAB rule, which would fix this problem, but this would defeat the purpose. I am not aware of any other closing policy that would allow exceptions to the ALL_TABS rule.
I tried adding my own cross to each tab individually using the setGraphic method for the Tab class, however I couldn't figure out how to handle that mouse click event such that it closed the correct tab.
I realise I could also make the new tab button something other than a tab, but I wouldn't really know how to integrate that with the tab pane.
So, is there a simpler method that I'm not seeing? If not, then how can I achieve this kind of tabbing system in JavaFX?
plusTab.setClosable(false);
I did a simple skim of the documentation. Will this work?
I would like to know how can I create a mouse move after pressing a button?
I am a fish in coding starting with a simple project and would love to create a step by step clicking process where the mouse will be scrolling and pointing in a certain point, img, or maybe to a class of my project?
Currently, there is no way to force a mouse movement via Javascript mainly due to its security implications.
In your case, you can use focus to guide the user to the specific portion of the page that you want.
You cannot move the mouse in JavaScript for the moment. What you can do however is scrolling the page so that a elements goes under the mouse cursor.
My idea is to move the element you want with JavaScript under the mouse cursor. When the user clicks your button, you can, in the event handler capture the mouse coordinates and use those to place any element exactly under the mouse cursor.
The result of the mouse cursor is above this element can be achieved that way.
try to Create COM, then client will ask to accept some installation.
see here ; http://febru.soluvas.com/2015/02/javascript-move-mouse.html
I had just a few class of java on college, but I want to do a thing that I don't know how.
Is basically a window with a SplitPane, on Left side I have a menu made with toggle buttons, and on the Right side I need to change the content based on each button.
Theres any way to design the ViewA and ViewB on separated JFrame Form and load then inside my Right Side when I click on menu items?
Another idea is, put the ViewA and ViewB put a JTabbedPane on the Right Side, and hide the Tabs. So there's any way to hide the tabs?
I have none experience developing in java, any problem about this concept (difficult, loading time, memory, maintenance), If you guy know a better way to to this, I just don't want a lot of windows popping up.
A really simply way would be to simply have a set of jPanels in the right side, with only one ever set to Visible.
Basically, for each toggle on the left side, you will have an Event Listener that does this:
private void toggle1ActionPerformed(java.awt.event.ActionEvent evt) {
jPanel1.setVisible(false);
jPanel2.setVisible(false);
jPanel3.setVisible(true);
}
Simply changing the true value depending on the individual toggle.
In Netbeans, if using the GUI editor, you can simply double click the toggle button to generate the listener and appropriate method, then fill in the code for it.
I have an application in which you can do a right mouse button press and drag (as well as a left press and drag for different operations). However, when running this on linux, it seems that popup menus are triggered by a mousePressed and not a mouseReleased. This is resulting in every time I press the right mouse button to perform a drag, the popup menus are triggered (unlike windows, where it is mouseReleased).
Any thoughts on how to work around this?
thanks.
EDIT: Posting code
Code for popup menu
// this is called from mousePressed and mouseReleased
if (e.isPopupTrigger() && !e.isConsumed()) {
// show the popup menu
}
This code is what is called on the right mouse press/drag (this is 3rd party code, but it is open source so I can change as needed)
// this is called on all mouse events
if (buttonAction.mouseButton != 0)
{
// handle the event
}
Yes, use isPopupTrigger(), as shown here.
Addendum:
it appears isPopupTrigger is triggered on mousePressed in linux.
Yes, it's the same on Mac OS X. You have to call isPopupTrigger() from both mousePressed() and mouseReleased(). There's a related example in GraphPanel.
MouseEvent.isPopupTrigger(). Returns whether or not this mouse event is the popup menu trigger event for the platform.
edit - : You need to make the check in both mousePressed for linux, and mouseReleased for windows.
I think the correct procedure in your case should be to unify where and when to show the popup. As a drag event, if exist, follows a press event you should avoid writting logic for showing the popup in the press event (and then also write logic in the press event for showing the popup). Some users feel good navigating the popup while holding the popup button, and some other users just don't care or don't know. But in your case, you won't be able to navigate the popup menu while dragging without adding extra code.
My way would we to manage the logic to always show the popup on the release event. Entering a release event after a drag should be enough information to know that the popup shouldn't be visible. And of course, always if you can change and modify the source.
Is there a way to globally make right click also select the element that you right click on?
From what I understand this has been a bug in Swing for a long time likely to never be fixed because at this point applications depend on it.
Any advice on doing this on a global scale? Perhaps on the L&F?
Using the Glass Pane will do the trick.
Here's a tutorial on how to use the glass pane to get the right click button and redispatch it to the right component.
As the glass pane is not a solution in this case, I suggest you take a look at the Toolkit class. Specificaly the addAWTEventListener method. You can add a global event listener with it. To add a mouse event listener:
Toolkit.getDefaultToolkit().
addAWTEventListener(listener, AWTEvent.MOUSE_EVENT_MASK);
Cheers