KeyListener First Key Typed

I

Ike

How can you tell, in a KeyListener, what the length of the document is? I'm
struggling with wanting to only do something on the first key pressed on a
document, and after that, to ignore the KeyPress altogether, but cannot
figure out the length of the underlying document.

Anyone encounter this before? -Ike
 
R

Rhino

Ike said:
How can you tell, in a KeyListener, what the length of the document is?
I'm
struggling with wanting to only do something on the first key pressed on a
document, and after that, to ignore the KeyPress altogether, but cannot
figure out the length of the underlying document.

Anyone encounter this before? -Ike
Why do you care about the document length? If you are only intended to
capture or react to the first key pressed, that has nothing to do with the
document length as far as I can see. You should only need to monitor your
KeyListener increment a counter for each key pressed; then ignore everything
but the first key press (or disable the listener altogether after the first
key press.) Right?
 
M

Martin Gregorie

Ike said:
How can you tell, in a KeyListener, what the length of the document is? I'm
struggling with wanting to only do something on the first key pressed on a
document, and after that, to ignore the KeyPress altogether, but cannot
figure out the length of the underlying document.
Why would you *care* how long the document is? The problem as you
describe it, is independent of document size. All you want to know is
whether its the first key pressed or not.

Sounds like a "first keystroke" boolean in your KeyListener is the
correct solution.
 
C

Chris Smith

Ike said:
How can you tell, in a KeyListener, what the length of the document is? I'm
struggling with wanting to only do something on the first key pressed on a
document, and after that, to ignore the KeyPress altogether, but cannot
figure out the length of the underlying document.

Anyone encounter this before? -Ike

I suppose you'd give the KeyListener access to the Document, perhaps by
passing it as a parameter to the constructor.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top