I'd like to know if it's possible to navigate through Vaadin grid or treegrid and select an item using only keyboard arrow keys? From what i've seen while testing the components, the default behavior seems to be either to move only to one specific cell in grid or to a specific row in treegrid. Selection can be achieved if the user presses spacebar.
I've tried to add a shortcutListener to grid but it doesn't seem to work with arrow keys. And the grid scrollbar doesn't move with the selected item.
grid.addShortcutListener(new ShortcutListener("Down", KeyCode.ARROW_DOWN, null) {
#Override
public void handleAction(Object sender, Object target) {
//..//
selectedItem = dataSource.get(currentSelectedItemIndex);
grid.select(selectedItem);
grid.scrollTo(currentSelectedItemIndex); // this doesn't seem to do anything??
//..//
}
});
I guess my problem is that i don't know how to acquire event that moves selection to other cell/row.
Here's an image to represent the problem which i'm facing. The item that has only blue border was selected using arrow keys. I'd like to select an item automatically when user presses arrow keys (Down or Up) without the spacebar.
Image taken from here: https://demo.vaadin.com/sampler/#ui/grids-and-trees/grid/features
Edit1:
I'm using latest version of Vaadin - 8.1.6.
Edit2:
I tried to add couple of listeners to see if i could at least register the movement to the next/previous cell by using arrow up/down but without any luck.
Here's a list of listeners i've tried:
addSelectionListener - only registers selection after spacebar press
or mouse click. Not quite what i'm looking for.
addItemClickListener - only registers selection from mouse click.
addShortcutListener - registers pressed key but it doesn't work with arrows.
Is there any listener that could potentially help me with this issue?
The Grid component has basic keyboard navigation. If you need advanced options, like you have mentioned, for keyboard navigation, I would warmly recommend to test this add-on:
https://vaadin.com/directory/component/gridfastnavigation-add-on
Related
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'm attempting to make an auto complete combo box in javafx, but I'm having an issue that I can't seem to solve.
When a user presses the up or down arrow when the combo box is showing, it changes the selected item. Is there anyway disable this functionality such that when an up or down arrow is pressed, it still "highlights" the next or previous item, but doesn't actually change the selection model?
It seems that the arrow key pressed is being registered as an ActionEvent but consuming this event doesn't actually stop the selection from changing.
Any insight would be greatly appreciated, and I can give a SSCE if necessary.
I can change the item's focus by pressing the arrow keys on the keyboard or by moving the mouse over it. Is there a programmatic way to move the focus around the items?
You can simply set the selected item. Optionally, you can show the dropdown list:
comboBox.requestFocus();
comboBox.showPopup();
comboBox.setSelectedIndex(selectedIndex);
Following is an UI:
There is an Up button and a down button in the UI, when clicking the Up/down button, the selected item(e.g. lib/logger.jar) in the left table(I assume it is a table, because I will create a table to show the items in my Application) will be moved up/down.
Question: How to add function to the Up/Down button, so the item in the table will be moved after clicking the Up/Down button?
BTW, I am using Java SWT/JFace.
If it is a table, you will work with TableItems. To move a TableItem, you have to dispose the one you want to move and create a new one using the constructor that receives an index as one of its arguments. This index is where the new TableItem will be placed.
I wanted to select an object inside the JFrame and move it with the keyboard arrow keys. I did the keyboard thing, whenever I pressed the arrow keys it moves accordingly to the direction. What I want is to move multiple objects. I tried to put an multiple objects and they did moved at the same time xD
tldr; is there a way where you can click on just one object using the mouse and control it with keyboard arrow keys?
Eventhough question not clear enough, moving single or multiple objects is not a problem. You need to use KeyEvent Listener for the object you want to listen and move the components based on KeyEvent.
Here some reference: http://download.oracle.com/javase/tutorial/uiswing/events/keylistener.html