summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-02-17 11:16:35 +0000
committerJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-02-17 11:16:35 +0000
commit48c92ababb7349ea0be7065886860277b67affa0 (patch)
tree595312fd1e4666e8d4b91e195b1a88334f218473
parentb85cc4e7915de55f04809627a628dd0d41792960 (diff)
downloadvaadin-framework-48c92ababb7349ea0be7065886860277b67affa0.tar.gz
vaadin-framework-48c92ababb7349ea0be7065886860277b67affa0.zip
#5100 Use FocusImpl to handle focus; allow customization of shortcut keys
svn changeset:23056/svn branch:6.8
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
index 2a12238c4b..4364989fe1 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
@@ -101,7 +101,8 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
this.tabBar = tabBar;
setStyleName(td, TD_CLASSNAME);
- div = DOM.createDiv();
+ div = focusImpl.createFocusable();
+ focusImpl.setTabIndex(div, -1);
setStyleName(div, DIV_CLASSNAME);
DOM.appendChild(td, div);
@@ -156,7 +157,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
*/
public void setStyleNames(boolean selected, boolean first) {
// TODO #5100 doesn't belong here
- td.setAttribute("tabindex", selected ? "0" : "-1");
+ focusImpl.setTabIndex(div, selected ? 0 : -1);
setStyleName(td, TD_FIRST_CLASSNAME, first);
setStyleName(td, TD_SELECTED_CLASSNAME, selected);
@@ -217,11 +218,11 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
}
public void focus() {
- td.focus();
+ focusImpl.focus(div);
}
public void blur() {
- td.blur();
+ focusImpl.blur(div);
}
}
@@ -1307,16 +1308,16 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
if (event.getSource() instanceof Tab) {
VConsole.log("KEYDOWN");
int keycode = event.getNativeEvent().getKeyCode();
- if (keycode == KeyCodes.KEY_LEFT) {
+ if (keycode == getPreviousTabKey()) {
int newTabIndex = activeTabIndex == 0 ? tb.getTabCount() - 1
: activeTabIndex - 1;
onTabSelected(newTabIndex);
activeTabIndex = newTabIndex;
- } else if (keycode == KeyCodes.KEY_RIGHT) {
+ } else if (keycode == getNextTabKey()) {
int newTabIndex = (activeTabIndex + 1) % tb.getTabCount();
onTabSelected(newTabIndex);
activeTabIndex = newTabIndex;
- } else if (keycode == KeyCodes.KEY_DELETE) {
+ } else if (keycode == getCloseTabKey()) {
VConsole.log("INDEX=" + activeTabIndex);
focusedTab.onClose();
removeTab(activeTabIndex);
@@ -1324,4 +1325,16 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
VConsole.log("tabindex -> " + activeTabIndex);
}
}
+
+ protected int getPreviousTabKey() {
+ return KeyCodes.KEY_LEFT;
+ }
+
+ protected int getNextTabKey() {
+ return KeyCodes.KEY_RIGHT;
+ }
+
+ protected int getCloseTabKey() {
+ return KeyCodes.KEY_DELETE;
+ }
}