Now posting key event directly to host component.

X-SVN-Rev: 1225
This commit is contained in:
Alan Liu 2000-04-22 17:10:10 +00:00
parent d7486cddca
commit 995ca45baa
5 changed files with 37 additions and 28 deletions

View File

@ -1,5 +1,5 @@
/*
* @(#)$RCSfile: ATextPanelImpl.java,v $ $Revision: 1.1 $ $Date: 2000/04/20 17:51:23 $
* @(#)$RCSfile: ATextPanelImpl.java,v $ $Revision: 1.2 $ $Date: 2000/04/22 17:10:10 $
*
* (C) Copyright IBM Corp. 1998-1999. All Rights Reserved.
*
@ -746,16 +746,10 @@ final class ATextPanelImpl {
* This method is for perf-testing only!
*/
void handleKeyEvent(java.awt.event.KeyEvent keyEvent) {
switch (keyEvent.getID()) {
case java.awt.event.KeyEvent.KEY_PRESSED:
fTextComponent.keyPressed(keyEvent);
break;
case java.awt.event.KeyEvent.KEY_TYPED:
fTextComponent.keyTyped(keyEvent);
break;
case java.awt.event.KeyEvent.KEY_RELEASED:
fTextComponent.keyReleased(keyEvent);
break;
Component host = fTextComponent.getHost();
if (host != null) {
host.dispatchEvent(keyEvent);
}
}
}

View File

@ -1,5 +1,5 @@
/*
* @(#)$RCSfile: JTextPanel.java,v $ $Revision: 1.1 $ $Date: 2000/04/20 17:51:23 $
* @(#)$RCSfile: JTextPanel.java,v $ $Revision: 1.2 $ $Date: 2000/04/22 17:10:10 $
*
* (C) Copyright IBM Corp. 1998-1999. All Rights Reserved.
*
@ -562,10 +562,10 @@ public final class JTextPanel extends JPanel implements MTextPanel {
}
/**
* This method is for perf-testing only!
* This method is for KeyEventForwarder's use only!
*/
void handleKeyEvent(java.awt.event.KeyEvent keyEvent) {
ATextPanelImpl getImpl() {
fImpl.handleKeyEvent(keyEvent);
return fImpl;
}
}

View File

@ -1,5 +1,5 @@
/*
* @(#)$RCSfile: KeyEventForwarder.java,v $ $Revision: 1.1 $ $Date: 2000/04/20 17:51:23 $
* @(#)$RCSfile: KeyEventForwarder.java,v $ $Revision: 1.2 $ $Date: 2000/04/22 17:10:10 $
*
* (C) Copyright IBM Corp. 1998-1999. All Rights Reserved.
*
@ -19,21 +19,28 @@ import java.awt.event.KeyEvent;
/**
* This class forwards key events to a TextPanel component for
* testing purposes.
* It's sole reason for existence is to prevent the key-event
* API from being public on TextPanel, and being mistaken for
* standard API. This class is only for testing!
* Its sole reason for existence is to prevent the key-event
* API from being public on MTextPanel, and being mistaken for
* standard API. This class is only for testing! It may be
* removed from public API at any time. Do not depend on this
* class.
*/
public final class KeyEventForwarder {
private TextPanel fRichText;
private ATextPanelImpl fPanelImpl;
public KeyEventForwarder(TextPanel richText) {
public KeyEventForwarder(TextPanel textPanel) {
fRichText = richText;
fPanelImpl = textPanel.getImpl();
}
public KeyEventForwarder(JTextPanel textPanel) {
fPanelImpl = textPanel.getImpl();
}
public void handleKeyEvent(KeyEvent keyEvent) {
fRichText.handleKeyEvent(keyEvent);
fPanelImpl.handleKeyEvent(keyEvent);
}
}

View File

@ -1,5 +1,5 @@
/*
* @(#)$RCSfile: TextComponent.java,v $ $Revision: 1.1 $ $Date: 2000/04/20 17:51:23 $
* @(#)$RCSfile: TextComponent.java,v $ $Revision: 1.2 $ $Date: 2000/04/22 17:10:10 $
*
* (C) Copyright IBM Corp. 1998-1999. All Rights Reserved.
*
@ -149,6 +149,14 @@ class TextComponent extends FakeComponent
});
}
/**
* ATextPanelImpl's use only!
*/
Component getHost() {
return fHost;
}
// Create document view here. TextComponent isn't fully constructed
// until this is called.
// This must be called by host component!

View File

@ -1,5 +1,5 @@
/*
* @(#)$RCSfile: TextPanel.java,v $ $Revision: 1.1 $ $Date: 2000/04/20 17:51:23 $
* @(#)$RCSfile: TextPanel.java,v $ $Revision: 1.2 $ $Date: 2000/04/22 17:10:10 $
*
* (C) Copyright IBM Corp. 1998-1999. All Rights Reserved.
*
@ -534,10 +534,10 @@ public final class TextPanel extends Panel implements MTextPanel {
}
/**
* This method is for perf-testing only!
* This method is for KeyEventForwarder's use only!
*/
void handleKeyEvent(java.awt.event.KeyEvent keyEvent) {
ATextPanelImpl getImpl() {
fImpl.handleKeyEvent(keyEvent);
return fImpl;
}
}