removeTabBlockHandlers();
}
+ private void addTabBlockHandlers() {
+ if (topBlockerRegistration == null) {
+ topBlockerRegistration = Event
+ .addNativePreviewHandler(topEventBlocker);
+ bottomBlockerRegistration = Event
+ .addNativePreviewHandler(bottomEventBlocker);
+ }
+ }
+
private void removeTabBlockHandlers() {
if (topBlockerRegistration != null) {
topBlockerRegistration.removeHandler();
if (isAttached()) {
showModalityCurtain();
}
+ addTabBlockHandlers();
deferOrdering();
} else {
if (modalityCurtain != null) {
}
modalityCurtain = null;
}
+ if (!doTabStop) {
+ removeTabBlockHandlers();
+ }
}
}
/**
* Registers the handlers that prevent to leave the window using the
* Tab-key.
+ * <p>
+ * The value of the parameter doTabStop is stored and used for non-modal
+ * windows. For modal windows, the handlers are always registered, while
+ * preserving the stored value.
*
* @param doTabStop
* true to prevent leaving the window, false to allow leaving the
- * window
+ * window for non modal windows
*/
public void setTabStopEnabled(boolean doTabStop) {
this.doTabStop = doTabStop;
- if (doTabStop) {
- if (topBlockerRegistration == null) {
- topBlockerRegistration = Event
- .addNativePreviewHandler(topEventBlocker);
- bottomBlockerRegistration = Event
- .addNativePreviewHandler(bottomEventBlocker);
- }
+ if (doTabStop || vaadinModality) {
+ addTabBlockHandlers();
} else {
removeTabBlockHandlers();
}
/**
* Sets window modality. When a modal window is open, components outside
- * that window it cannot be accessed.
+ * that window cannot be accessed.
+ * <p>
+ * Keyboard navigation is restricted by blocking the tab key at the top and
+ * bottom of the window by activating the tab stop function internally.
*
* @param modal
* true if modality is to be turned on
}
/**
- * Set if it should be prevented to set the focus to a component outside the
- * window with the tab key.
+ * Set if it should be prevented to set the focus to a component outside a
+ * non-modal window with the tab key.
* <p>
* This is meant to help users of assistive devices to not leaving the
* window unintentionally.
+ * <p>
+ * For modal windows, this function is activated automatically, while
+ * preserving the stored value of tabStop.
*
* @param tabStop
* true to keep the focus inside the window when reaching the top