2 * Copyright 2000-2018 Vaadin Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
16 package com.vaadin.v7.client.ui.calendar.schedule;
18 import com.google.gwt.event.dom.client.BlurEvent;
19 import com.google.gwt.event.dom.client.BlurHandler;
20 import com.google.gwt.event.dom.client.FocusEvent;
21 import com.google.gwt.event.dom.client.FocusHandler;
22 import com.google.gwt.event.dom.client.HasBlurHandlers;
23 import com.google.gwt.event.dom.client.HasFocusHandlers;
24 import com.google.gwt.event.dom.client.HasKeyDownHandlers;
25 import com.google.gwt.event.dom.client.HasKeyPressHandlers;
26 import com.google.gwt.event.dom.client.KeyDownEvent;
27 import com.google.gwt.event.dom.client.KeyDownHandler;
28 import com.google.gwt.event.dom.client.KeyPressEvent;
29 import com.google.gwt.event.dom.client.KeyPressHandler;
30 import com.google.gwt.event.shared.HandlerRegistration;
31 import com.google.gwt.user.client.ui.ComplexPanel;
32 import com.google.gwt.user.client.ui.impl.FocusImpl;
33 import com.vaadin.client.Focusable;
36 * A ComplexPanel that can be focused.
42 public class FocusableComplexPanel extends ComplexPanel
43 implements HasFocusHandlers, HasBlurHandlers, HasKeyDownHandlers,
44 HasKeyPressHandlers, Focusable {
46 protected void makeFocusable() {
47 // make focusable, as we don't need access key magic we don't need to
48 // use FocusImpl.createFocusable
49 getElement().setTabIndex(0);
56 * com.google.gwt.event.dom.client.HasFocusHandlers#addFocusHandler(com.
57 * google.gwt.event.dom.client.FocusHandler)
60 public HandlerRegistration addFocusHandler(FocusHandler handler) {
61 return addDomHandler(handler, FocusEvent.getType());
68 * com.google.gwt.event.dom.client.HasBlurHandlers#addBlurHandler(com.google
69 * .gwt.event.dom.client.BlurHandler)
72 public HandlerRegistration addBlurHandler(BlurHandler handler) {
73 return addDomHandler(handler, BlurEvent.getType());
80 * com.google.gwt.event.dom.client.HasKeyDownHandlers#addKeyDownHandler(
81 * com.google.gwt.event.dom.client.KeyDownHandler)
84 public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
85 return addDomHandler(handler, KeyDownEvent.getType());
92 * com.google.gwt.event.dom.client.HasKeyPressHandlers#addKeyPressHandler
93 * (com.google.gwt.event.dom.client.KeyPressHandler)
96 public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) {
97 return addDomHandler(handler, KeyPressEvent.getType());
101 * Sets/Removes the keyboard focus to the panel.
104 * If set to true then the focus is moved to the panel, if set to
105 * false the focus is removed
107 public void setFocus(boolean focus) {
109 FocusImpl.getFocusImplForPanel().focus(getElement());
111 FocusImpl.getFocusImplForPanel().blur(getElement());
119 public void focus() {