[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

MAC and the CAPS LOCK key

Posted on 1997-06-05
2
Medium Priority
?
1,337 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
jpk041897 earned 240 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

656 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