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);
Related
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
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 am writing an Android App in which I am using Spinner Control. I customized my spinner control by creating my own list. I want to change the drop down arrow present beside the spinner control . Can anyone help me how to change the drop down arrow of spinner control . I want to replace that arrow by own arrow Image.
You have to make a style and then set that style of your spinner. The spinner's background with the arrow work as a button. So, if you make a style for a button with the various states button pressed, button selected then it will work for you. You can't change the arrow only, you have to change the full background. hope you have understand what I meant...
On click on next button, the list should highlight/select next item in the listview.
How can i achieve it without actually touching the list item directly on the screen?
ListView.setSelection(int pos) will help you to achieve this.
on next click u can change the background of the respective item and store the position for further work.this will be act as selected items
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.