RE: [OpenMap Users] receiving key events in a layer

From: Klawetter, DG Darol (6274) _at_ IS <darol.klawetter_at_L-3com.com>
Date: Mon, 16 May 2005 13:29:01 -0500

Here is a code snippet from my mouse processor module. Notice that only the
OpenMapFrame (i.e., top-level frame) is receiving the focus when Openmap is
not functioning as an applet.




public void mouseEntered(MouseEvent e) {
        Debug.message("map_api_mouse_proc", "MapAPI.mouseEntered");

        Object obj = e.getSource();
        if (Environment.isApplet())
        {
          mapBean.requestFocus();
          mapFrame.requestFocus(); // OpenMapFrame should receive focus
when mouse is over map
        }
        else if (mapFrame.isActive())
        {
           mapFrame.requestFocus(); // OpenMapFrame should receive focus
when mouse over an active window
        }

-----Original Message-----
From: Peter Wilkes [mailto:pwilkes_at_cowpie.acm.vt.edu]
Sent: Monday, May 16, 2005 1:23 PM
To: Klawetter, DG Darol (6274) _at_ IS
Cc: openmap-users_at_bbn.com
Subject: RE: [OpenMap Users] receiving key events in a layer


Darol,

        can i ask where you added this code? i still don't seem to be
picking up the events. i've tried this

MapPanel extends JPanel implements MouseListener, KeyListener
{
MapBean mapbean;
MapPanel()
{
...
mapbean.addKeyListener(this)
mapbean.addMouseListener(this)
...
}
...
public void keyPressed(KeyEvent e)
{
system.out.println("key pressed");
}

public void mouseEntered(MouseEvent e)
{
requestFocus();
system.out.println("focus requested");
}
}


with this i see the "focus requested" system outs however i don't seem to
see the "key pressed" system outs. if i change the code to have the
listeners goto the JPanel instead of the mapbean i don't seem to get
either system outs.

thanks for the help!

Pete


On Mon, 16 May 2005, Klawetter, DG Darol (6274) _at_ IS wrote:

> Hi Pete,
>
> To capture key strokes, you will not only have to add a key listener, but
> you will have to perform a "requestFocus()" in your map frame and/or
> mapBean. I performed the requestFocus upon a mouseEntered() event. I could
> not detect keystrokes until I did this.
>
> Darol
>
> -----Original Message-----
> From: owner-openmap-users_at_bbn.com [mailto:owner-openmap-users_at_bbn.com]On
> Behalf Of Peter Wilkes
> Sent: Monday, May 16, 2005 9:35 AM
> To: openmap-users_at_bbn.com
> Subject: [OpenMap Users] receiving key events in a layer
>
>
> Hello all!
>
> My client asked for additional Map functionality by cycling through the
> displayed map objects by pressing keys on the keyboard. they feel if a lot
> of items are displayed on the map this might make it easier to select map
> objects.
>
> i tried implementing KeyListener on my Layer to pick up key events however
> that did not seem to work. i also tried implementing KeyListener on the
> JPanel that contains the map bean however that did not seem to work.
>
> does anyone have any suggestions on how i could fulfill this
> functionality?
>
> thank you. any help is greatly appreciated.
>
> Pete
>
> --
> [To unsubscribe to this list send an email to "majdart_at_bbn.com"
> with the following text in the BODY of the message "unsubscribe
> openmap-users"]
>
> --
> [To unsubscribe to this list send an email to "majdart_at_bbn.com"
> with the following text in the BODY of the message "unsubscribe
openmap-users"]
>

--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Mon May 16 2005 - 14:29:25 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:06 EDT