Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User jawarnerjr's Avatar
    Join Date
    Oct 2005
    Posts
    14
    I have looked for hours through the WRT library and the rest of the documentation trying to find out the keyCode and/or charCode for Left and Right softkey press events.

    Can anyone tell me what they are? If they are not detectable in javascript running on WRT1.0, do you have any ideas about ways to tell that the user has pressed the left softkey (labeled "Done") or right (labeled "Cancel") after editing an INPUT element?

    Thanks.

  2. #2
    Nokia Developer Champion jappit's Avatar
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,391
    Hi jawarnerjr,

    afaik there's no way to directly detect a softkey press with standard JavaScript key events.

    In your case, if you want to detect a value change on an INPUT field, you could try by using its onchange JavaScript event handler.

    Hope it helps,
    Pit

  3. #3
    Registered User jzferreira's Avatar
    Join Date
    Sep 2008
    Location
    Manaus, Brazil
    Posts
    109
    I did some tests and I can't detect the right and left softkeys.
    Javier Zambrano Ferreira

  4. #4
    Regular Contributor hp3's Avatar
    Join Date
    Apr 2003
    Location
    Akron Ohio USA
    Posts
    229
    Its my understanding that the left softkey is always for an options menu, at least in WRT 1.0 and 1.1. It is not really a programmable key. You can use the menu object onShow method to detect when a user clicks the left softkey, but clicking the left softkey should still open a basic menu with atleast one option "exit". I dont think you can disable the menu opening behavior of the left softkey. I think this is based upon the conventions of the s60 user interface.

    Instead, you could create a control within the WRT application for "done" instead of using the left soft key.

    You can configure the right soft key to do what you want and assign a function to it.

    menu.setRightSoftkeyLabel("Cancel", notify);

    // function to execute when the user clicks the right softkey
    function notify(){
    alert('right softkey press');
    }

  5. #5
    Registered User jawarnerjr's Avatar
    Join Date
    Oct 2005
    Posts
    14
    Quote Originally Posted by jappit View Post
    Hi jawarnerjr,

    afaik there's no way to directly detect a softkey press with standard JavaScript key events.

    In your case, if you want to detect a value change on an INPUT field, you could try by using its onchange JavaScript event handler.

    Hope it helps,
    Pit
    Thanks for letting me know that there really was a reason I couldn't find anything.

    Using an onchange handler is what I have been doing, but it doesn't let me do error trapping as well as I would like. Part of (my) problem is that arrow key events also cause onchange firing and pressing the center key does not.

    Jim

  6. #6
    Registered User jawarnerjr's Avatar
    Join Date
    Oct 2005
    Posts
    14
    Quote Originally Posted by hp3 View Post
    Its my understanding that the left softkey is always for an options menu, at least in WRT 1.0 and 1.1. It is not really a programmable key. You can use the menu object onShow method to detect when a user clicks the left softkey, but clicking the left softkey should still open a basic menu with atleast one option "exit". I dont think you can disable the menu opening behavior of the left softkey. I think this is based upon the conventions of the s60 user interface.

    Instead, you could create a control within the WRT application for "done" instead of using the left soft key.

    You can configure the right soft key to do what you want and assign a function to it.

    menu.setRightSoftkeyLabel("Cancel", notify);

    // function to execute when the user clicks the right softkey
    function notify(){
    alert('right softkey press');
    }
    Thanks for your thoughts. When editing an INPUT, the LSK is given the "Done" label by default and RSK is "Cancel". I don't want or need to program either key; I just want to detect when either is pressed.

    1) Can you give me an example of how I could use menu.onShow()to tell that the LSK was pressed? Does it return true? Would it be something like using an onchange event handler like this:
    ChangeHandler(){
    if (menu.onShow()){
    // LSK was pressed
    ...
    }}

    2) As you suggested, how can I create a control for "Done" or "Cancel"?

    3) Ingenious idea to use the softkey labeling, not as a way to change the label - which I don't need to do, but to attach a function. In all the searching I did, I thought I remembered that the LSK label could also be programmed. Will check. Anyway, at least a combination of (1) for the LSK and (2) or (3) for the RSK should give me the granularity I need. Thanks so much.

    Jim

  7. #7
    Regular Contributor hp3's Avatar
    Join Date
    Apr 2003
    Location
    Akron Ohio USA
    Posts
    229
    one correction to my previous post, onShow is an event not a method. So all you need to do is assign your function to the onShow event.

    menu.onShow = yourfunctionobject

    or

    menu.onShow = function(){your code}

    but the menu will still open when the user presses the left softkey.

    As an alternative you could have, what I referred to as a control for "done", which is just a link or standard HTML form input button type that has an event handler for your javascript. The user would either press this control on touch screen or navigate to the control for keypad device. It would not be a physical key, but rather an on-screen interface element.

    I suppose you could also have the user press the center key of the 5 way keypad which is a conventional way for ok'ing an action. You can trap the keypress for this key with javascript.

  8. #8
    Registered User jawarnerjr's Avatar
    Join Date
    Oct 2005
    Posts
    14
    Quote Originally Posted by hp3 View Post
    one correction to my previous post, onShow is an event not a method. So all you need to do is assign your function to the onShow event.

    menu.onShow = yourfunctionobject

    or

    menu.onShow = function(){your code}

    but the menu will still open when the user presses the left softkey.

    As an alternative you could have, what I referred to as a control for "done", which is just a link or standard HTML form input button type that has an event handler for your javascript. The user would either press this control on touch screen or navigate to the control for keypad device. It would not be a physical key, but rather an on-screen interface element.

    I suppose you could also have the user press the center key of the 5 way keypad which is a conventional way for ok'ing an action. You can trap the keypress for this key with javascript.
    Thanks for the clarification. That helps a lot. The S60 default for editing is a keyLabel of "Done" without a menu so onShow shouldn't display anything. Being able to use the event should work just fine. Then I can use your idea of
    menu.setRightSoftkeyLabel("Cancel", notify);
    to set the function for the RSK.

    My UI would want to avoid an on-screen button and extra navigation, but that would work.

    I would very much like to use a center key press to OK the end of the edit and to run the same function "Done" does. I have found, however, that pressing OK on an INPUT does not issue a keypress or keydown event. I am able to capture an evt.charCode of "63557" under different circumstances and I use it now, but not while editing an INPUT. It seems that the UI designers really had a very singular idea of how users would enter text. If you have an alternative way I can do that, I would be delighted to know.

    This combination should let me:
    1. take an action according to the onchange handler if any Arrow key is pressed
    2. take a different action if "Cancel" is chosen
    3. take a third action if "Done" is pressed.
    If pressing OK could be detected and mapped to the same function as the onShow handler, I would have the complete package.

    Thanks so much for your help and ideas - especially from my old hometown!

  9. #9
    Registered User jawarnerjr's Avatar
    Join Date
    Oct 2005
    Posts
    14
    Quote Originally Posted by jawarnerjr View Post
    Thanks for the clarification. That helps a lot. The S60 default for editing is a keyLabel of "Done" without a menu so onShow shouldn't display anything. Being able to use the event should work just fine.
    Well, I was wrong. My test shows that menu.onShow fires only when there is not an INPUT with focus, i.e., onShow only works when I don't need it. GRRRRRR!

    The ONLY way to do this is for onblur to do nothing (so arrow keys do nothing), let a "Done" press fix the INPUT value, then have an "OK" fire the search function. That will require your idea of a button control which really adds a layer of cumbersomeness and extra navigation to the UI.

    Nokia guys: PLEASE let us make it easier for the poor users; let us detect a "Done" or "OK"(charCode on keydown = 63557) pressed when an INPUT has focus.

Similar Threads

  1. Problem while detecting long key press...
    By rohanwaugh in forum Symbian C++
    Replies: 1
    Last Post: 2009-03-31, 09:39
  2. app crash with softkey press
    By redfoodegm in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 4
    Last Post: 2007-01-24, 18:47
  3. Simulating Long Key Press event in debugging mode...
    By empeegee in forum Symbian C++
    Replies: 6
    Last Post: 2004-12-22, 05:24
  4. Nokia 6260 camera button event for Long press
    By paulsanbu in forum Symbian C++
    Replies: 1
    Last Post: 2004-12-18, 06:40
  5. Simulating Long Key Press event in debugging mode...
    By empeegee in forum Multimodecards
    Replies: 1
    Last Post: 2004-12-18, 06:31

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved