keyboard events dont seem to work in mozilla?

GWT Designer allows you to quickly create the modules, composites, panels, remote services and other elements that comprise Google Web Tookit applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

keyboard events dont seem to work in mozilla?

Postby ndesk1900 » Fri Jun 20, 2008 9:19 am

Hello all,

Here's some very straightforward code to capture keyboard events. It
works find in hosted mode (and IE), however in mozilla 3.0 it seems to
not respond to keyboard events..

-----------------------------------------------------------------------------------------------------
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.KeyboardListener;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.TextBox;

public class Workbench extends VerticalPanel implements EntryPoint {
TextBox tb;

public void onModuleLoad() {
tb = new TextBox();
add(tb);
setSize("200px", "200px");
DOM.setStyleAttribute(this.getElement(), "background", "red");

sinkEvents(Event.KEYEVENTS);
RootPanel.get().add(this);
}

public void onBrowserEvent(Event e) {

int type = DOM.eventGetType(e);
Element el = DOM.eventGetFromElement(e);

if ( type == Event.ONKEYDOWN ) {
if ( KeyboardListener.KEY_CTRL == DOM.eventGetKeyCode(e) ) {
tb.setText("Ctrl Pressed");
}

if ( KeyboardListener.KEY_SHIFT == DOM.eventGetKeyCode(e) ) {
tb.setText("Shift Pressed");
}
}

if ( type == Event.ONKEYUP ) {
if ( KeyboardListener.KEY_CTRL == DOM.eventGetKeyCode(e) ) {
tb.setText("Ctrl Left");
}

if ( KeyboardListener.KEY_SHIFT == DOM.eventGetKeyCode(e) ) {
tb.setText("Shift Left");
}
}
}
}
ndesk1900
 
Posts: 1
Joined: Fri Jun 20, 2008 9:15 am

Re: keyboard events dont seem to work in mozilla?

Postby Eric Clayberg » Fri Jun 20, 2008 1:01 pm

Did you have a GWT Designer related question?

General GWT issues should be reported to Google's GWT forum.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to GWT Designer

Who is online

Users browsing this forum: No registered users and 3 guests