Solved

MAC and the CAPS LOCK key

Posted on 1997-06-05
2
1,325 Views
Last Modified: 2010-05-19
Using Netscape 3 on a MAC:

The CAPS LOCK key seems to be ignored in TextArea and TextFields that are drawn in the Applet window.  TextFields/Areas drawn in a Dialog box recognize the CAPS LOCK key.  And I've seen inconsistent behavior in this regard with additional Frames.  I can't determine what the significant difference is between those frames that work and thos that don't.  Has anyone seen this?  Have a explanation or work around?
0
Comment
Question by:mlimotte
2 Comments
 
LVL 6

Accepted Solution

by:
jpk041897 earned 80 total points
ID: 1221269
Take a look at:

http://www.geocities.com/Athens/7077/Java072.htm

this page contains a class, called Event05, that subclasses textField.

This particular class has the ability of monitoring the Events that happen in a textField and displaying them (I used it succesfully to limit the ammount of characters that can be inputed to a textField).

By using this class you can figure out if the CAPS LOCK key is actualy sending anything or not. (and what its sending).

Once you have figured this out, I can suggest a workarround:

Modify the Event05 class to behave like an almost normal textField but add a CapsLock flag and an if statment that tests for the flag.

Inside the if block, you can implement code that adds the ASCII offset for a normal and Cap'd letters. (I forget the actual value, 27 I think) but it can be calculated with 'a' -'A')

This class can also aid you in figuring out whats going on with the other question you posted.

For reference, and to cut back a little time on the modifed version you would need if this suggestion actualy solves your problem, I'm posting the code I used to limit the characters in a textField. Of course, the same logic applies to textAreas.

import java.awt.*;

//Define a custom TextField class that can respond to events.
//  Note that this class extends TextField.
class TF extends TextField{

  int maxCount = 5;
  int count = 0;       
  TF(String inString, int MaxCount){
     setText(inString);
     maxCount = MaxCount;
  }//end constructor

  //The following event handler method handles events at the
  // component level as opposed to the container level.
  public boolean handleEvent(Event evObj){
 
    switch(evObj.id){
      case Event.KEY_PRESS :
        if (count < maxCount){
             char[] c = new char[1];
             c[0]= (char) evObj.key;
             String s = new String(c);
             setText(getText() + s);
             count++;
          }
          break;
      default : //catch and display all other event types here
          break;
    }//end switch
    return super.handleEvent(evObj);
  }//end handleEvent() in class TF
 
}//end class TF
//===================================================================

You can easily modify this class to acomplish a simulation of th CAPS LOCK key, provided it realy is sending sata to the app.
0
 
LVL 1

Author Comment

by:mlimotte
ID: 1221270
The CAPS LOCK key alone does not produce an event.  But, your suggestion prompted me to look at the events and I realized that when the CAPS LOCK key is down the proper CAPITALIZED ascii value is sent (i.e. A=97 as opposed to 65), but the shift modifier is not sent.  Certain MAC AWT components apparently lowercase the ascii value unless the shift modifier is on.  So, my solution was to resend these bad events with the shift modifier.

I gave a B grade, becuase the answer was not completely correct, but it did suggest an avenue of investigation.

I had already used this method with the COMMAND key, but apparently no event is generated for these key presses.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Core Java. What output will be and why ? 6 66
eclipse shortcuts 9 45
Spring Framework HTTPSession management 1 24
MySqlDump not dumping triggers 1 19
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now