×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Dec 2009
    Posts
    59

    Soft buttons in full screen mode

    Hi again,

    I searched the internet, but i didn't find anything, how do i get the soft buttons ?
    I'm using a canvas in full screen mode and i want to get the soft buttons in keyPressed just like all the other buttons, how can i do that ?

    Thanks,
    Alex

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Soft buttons in full screen mode

    First: don't attach any Commands or a CommandListener to the Canvas. Doing this might disable keyPressed() events for the softkeys.

    Softkeys have key codes just like any other key. The one slight problem is: they don't have standard codes like 0-9, * and # do. Same goes for dpad (direction pad, the up-down-left-right control).

    You may be using getGameAction() to access the dpad control. I recommend you don't. Use the key codes instead. Yes, these will vary from device to device, but so will the softkey codes, so this is a problem you will have to deal with anyway. The problem with game-actions is that they are unpredictable. You never know which keys will map to which actions. You will often find, for example, that 2, 4, 6 and 8 also map to up, left, right and down, as will as the dpad. 5 often maps to fire, but then again it might be 0. Or the left softkey. Or send (green key). Or all of them. This particularly becomes a problem if you mix game-actions and raw key-codes in the same keyPressed() event. It can make the help text hard to get right (since you don't know which keys the use must use).

    OK... having abandoned game-actions, which codes do you use?

    You might want to create a class like this:

    Code:
    public class Keys {
        public static final int LEFT_SOFT = com.nokia.mid.ui.FullCanvas.KEY_SOFTKEY1;
        public static final int RIGHT_SOFT = com.nokia.mid.ui.FullCanvas.KEY_SOFTKEY2;
        public static final int SELECT = com.nokia.mid.ui.FullCanvas.KEY_SOFTKEY3;
    
        public static final int UP = com.nokia.mid.ui.FullCanvas.KEY_UP_ARROW;
        public static final int LEFT = com.nokia.mid.ui.FullCanvas.KEY_LEFT_ARROW;
        public static final int RIGHT = com.nokia.mid.ui.FullCanvas.KEY_RIGHT_ARROW;
        public static final int DOWN = com.nokia.mid.ui.FullCanvas.KEY_DOWN_ARROW;
    }
    I've referenced these from the Nokia API. If you like, you can hard-code them as literals:

    Code:
    public class Keys {
        public static final int LEFT_SOFT  = -6;
        public static final int RIGHT_SOFT = -7;
        public static final int SELECT     = -5;
    
        public static final int UP         = -1;
        public static final int LEFT       = -3;
        public static final int RIGHT      = -4;
        public static final int DOWN       = -2;
    }
    This will enable you to build without having the Nokia API in your classpath.

    These values are correct for the current Sun emulator, for all Nokia devices (one or two Nokias don't have a SELECT (dpad-centre) key), and all MIDP-2 Sony Ericsson devices. They also work on some Samsungs, and one or two other devices.

    For other devices, you can have different versions of this class, and produce device-specific builds.

    Another alternative is to put the codes in a resource file in the JAR, and read them from there. I don't favour this approach. If you're going to generate different JARs, you might as well re-compile.

    Thirdly, you could consider putting them in the JAD, so you don't need to have different JARs, just different JADs. Use MIDlet.getAppProperty() to read information from the JAD.

    Having them in code (as shown above) generates the smallest, fastest code, if that's important for you.

    Graham.

  3. #3
    Regular Contributor
    Join Date
    Dec 2009
    Posts
    59

    Re: Soft buttons in full screen mode

    Wow! I can't believe this is not explained anywhere else. Thanks, you're great!

  4. #4
    Regular Contributor
    Join Date
    Dec 2009
    Posts
    59

    Re: Soft buttons in full screen mode

    Could you also tell me the values for C (backspace), * and # ?

    Thank you.

  5. #5
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Soft buttons in full screen mode

    * is Canvas.KEY_STAR and # is Canvas.KEY_POUND.

    The "C" key on Series 60's is -8, but this is undocumented. I'm not 100% sure it generates a key event on all Series 60s. Remember that Series 40 devices don't have this key (nor do many non-Nokia devices).

    Some keys don't generate key events.

    You might want to build yourself a small test-app that displays the codes passed to keyPressed() and keyReleased(). Forget keyRepeated(), some devices don't support it, and it's generally not very useful. You should check both pressed and released events, because some keys on some devices don't generate a released event. Notably, softkeys on some non-Nokia devices don't generate a released event. With a suitable test app, you will be able to find which keys generate events, with what codes, and try this on different devices.

    Graham.

  6. #6
    Regular Contributor
    Join Date
    Dec 2009
    Posts
    59

    Re: Soft buttons in full screen mode

    How many don't support keyRepeated() ?

    I created my own (low-level) TextField, and i would like to be able to go left or right faster.

  7. #7
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Soft buttons in full screen mode

    I'm not sure, I never use it (because some devices don't support it). Canvas.hasRepeatEvents() will return true if repeat events are supported. I think all Nokias support keyRepeated().

    Graham.

  8. #8
    Regular Contributor
    Join Date
    Dec 2009
    Posts
    59

    Re: Soft buttons in full screen mode

    Oook, thanks, you've been very helpfull.

Similar Threads

  1. Full Screen and system dialogs
    By juannoguera in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-12-22, 09:51
  2. Full Screen Mode and Fire Key
    By mooncat69 in forum Mobile Java General
    Replies: 4
    Last Post: 2008-10-22, 10:32
  3. from full screen to normal screen
    By Skygyl in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-08-21, 06:56
  4. Full Screen Debug on ALL Carbide c++ versions in Windows XP
    By jimgilmour1 in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 0
    Last Post: 2007-04-27, 18:33
  5. UI: Full Screen Mode
    By GENERAL_INFO in forum Symbian User Interface
    Replies: 3
    Last Post: 2004-11-22, 06:27

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×