Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #5205

Re: Passing KeyEvent upward

From Adam Beneschan <adam@irvine.com>
Newsgroups comp.lang.java.gui
Subject Re: Passing KeyEvent upward
Date 2012-07-24 21:08 -0700
Organization http://groups.google.com
Message-ID <c1bd1298-3737-4cae-9364-111c729aa912@googlegroups.com> (permalink)
References <0f05834e-c654-4925-b78a-b8328b23ba0b@googlegroups.com> <jumvpu$djr$1@dont-email.me>

Show all headers | View raw


On Tuesday, July 24, 2012 1:15:56 PM UTC-7, Knute Johnson wrote:
> 
> You can just call processKeyEvent() on the JTextPane and pass it the 
> KeyEvent that you got from your JPopupMenu.  I don't think I would do 
> that though, I think I would create a non-modal Dialog instead of the 
> PopupMenu and put the focus back on to the JTextPane.  That's assuming 
> that you are doing what I think you are doing.

Thanks--processKeyEvent() actually did what I was trying to do.  (It's protected so I had to do a little extra work to make things work.)  I'm not sure it's the best way to do things, so I'm still planning on looking over everyone else's suggestions and reading the link Roedy pointed me to, so that I can figure out what's going on.

The "actual" situation (it's an experimental program only, to help me learn) is something like this:  Suppose you have a text window where you want the user to be able to enter and edit text; but at certain points, depending on what the user just typed in, the program may decide that there are two or more likely "completions" to the word (or whatever) that the user started typing.  So the program automatically brings up a menu.  The user can then select one of the completions off the menu.  But if she keeps typing, I want the key to work as it normally would if the menu hadn't popped up.  That's why I wanted to "pass it back up" (if that's the correct direction :)) to the text editing window, and let it handle it the way it would have with no menu.  (This kind of user interface is probably more complicated than necessary if the user were just typing in English text, but I have something else in mind.)

Thank you all for your help, I really appreciate it.  Even though I have *a* solution, I'm still planning on looking over the rest of the answers to learn whatever I can.

                                -- Adam
 

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Passing KeyEvent upward Adam Beneschan <adam@irvine.com> - 2012-07-22 16:09 -0700
  Re: Passing KeyEvent upward markspace <-@.> - 2012-07-22 17:26 -0700
    Re: Passing KeyEvent upward markspace <-@.> - 2012-07-22 17:39 -0700
    Re: Passing KeyEvent upward Adam Beneschan <adam@irvine.com> - 2012-07-23 21:15 -0700
      Re: Passing KeyEvent upward markspace <-@.> - 2012-07-23 23:08 -0700
  Re: Passing KeyEvent upward "John B. Matthews" <nospam@nospam.invalid> - 2012-07-22 21:32 -0400
  Re: Passing KeyEvent upward Roedy Green <see_website@mindprod.com.invalid> - 2012-07-23 23:46 -0700
  Re: Passing KeyEvent upward Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2012-07-24 13:15 -0700
    Re: Passing KeyEvent upward Adam Beneschan <adam@irvine.com> - 2012-07-24 21:08 -0700
      Re: Passing KeyEvent upward markspace <-@.> - 2012-07-24 22:50 -0700
  Re: Passing KeyEvent upward Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-07-25 00:32 +0200

csiph-web