Symbian
Symbian OS Library

FAQ-0781 Can a Java app interact with the menu and help keys in the 9200 Communicator series UI?

[Index][spacer] [Previous] [Next]



 

Classification: Java Category: AWT
Created: 04/09/2002 Modified: 04/09/2002
Number: FAQ-0781
Platform: Symbian OS v6.0

Question:
I would like to be able to simulate and/or handle menu and help keys in the context of the 9200 Communicator series UI. Is this possible and if so how?

Answer:
In the case of the help key, there is no difficulty. Key presses are simulated and handled in the standard AWT way. You need to dispatch or listen for keyPressed events with key code 152. These can be generated from the emulator with the F2 key.

    public void keyPressed(KeyEvent ke)
    {
    if(ke.getKeyCode()==152) System.out.println("Help key pressed");
    }

    In the case of the menu key, which has key code 148, key presses are processed by a native control higher up the stack than AWT event handling. So, if a MenuBar has been added to a Frame, a menu key press will always be intercepted and consumed, and the MenuBar displayed, with no AWT event generated. For the same reason, it is not possible to activate the MenuBar from within Java code: simulated keyPressed events with key code 148 will be processed as ordinary AWT events.

    However, if no (or a null) MenuBar has been added to the Frame, a menu key press will not be consumed but passed on to the AWT event handling mechanism as a key code 148. You can therefore provide custom handling of menu key presses if you wish.