×

Discussion Board

Results 1 to 12 of 12

Thread: left soft key

  1. #1
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    54

    left soft key

    Why is not possible to assign a function to the left soft key (Options)? If yes, how to? I've the same problem with the key_codes module: EKeyLeftSoftkey is not recognized. Thanks for you help.

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: left soft key

    You can detect when the left softkey is pressed with the keycapture module and call a function. See this thread and the PyS60 Library Reference for details.

  3. #3
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    54

    Re: left soft key

    Why the EKeyLeftSoftkey keypress function does not assign the "choise" selection list at the execution?
    Code:
    import appuifw
    import e32
    import keycapture
    from key_codes import *
    
    def choise():
        index = appuifw.selection_list(choices=L , search_field=1)
    
        if index == 0:
            appuifw.app.body=appuifw.Text("E32USER-CBase (63)")
            appuifw.app.exit_key_handler=choise
    
        if index == 1:
            appuifw.app.body=appuifw.Text("E32USER-CBase (69)")
            appuifw.app.exit_key_handler=choise
    
    L = [(u'E32USER-CBase 63'),(u'E32USER-CBase 69')]
    
    canvas = appuifw.Canvas() 
    appuifw.app.body = canvas
    
    def cb_capture(key):
        if key == EKeyRightSoftkey:
    	                print "Left softkey pressed"
        if key == EKeyLeftSoftkey:
    		        choise
    
    capturer = keycapture.KeyCapturer(cb_capture)
    capturer.keys = (EKeyRightSoftkey, EKeyLeftSoftkey)
    capturer.start()
    
    def exit_key_handler():
        app_lock.signal()
        appuifw.app.set_exit()
    
    app_lock = e32.Ao_lock()
    appuifw.app.exit_key_handler = exit_key_handler
    app_lock.wait()

  4. #4
    Nokia Developer Moderator
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: left soft key

    You have to call the function with the parantheses (marked in red):
    Code:
    import appuifw
    import e32
    import keycapture
    from key_codes import *
    
    def choise():
        index = appuifw.selection_list(choices=L , search_field=1)
    
        if index == 0:
            appuifw.app.body=appuifw.Text("E32USER-CBase (63)")
            appuifw.app.exit_key_handler=choise
    
        if index == 1:
            appuifw.app.body=appuifw.Text("E32USER-CBase (69)")
            appuifw.app.exit_key_handler=choise
    
    L = [(u'E32USER-CBase 63'),(u'E32USER-CBase 69')]
    
    canvas = appuifw.Canvas() 
    appuifw.app.body = canvas
    
    def cb_capture(key):
        if key == EKeyRightSoftkey:
    	                print "Left softkey pressed"
        if key == EKeyLeftSoftkey:
    		        choise()
    
    capturer = keycapture.KeyCapturer(cb_capture)
    capturer.keys = (EKeyRightSoftkey, EKeyLeftSoftkey)
    capturer.start()
    
    def exit_key_handler():
        app_lock.signal()
        appuifw.app.set_exit()
    
    app_lock = e32.Ao_lock()
    appuifw.app.exit_key_handler = exit_key_handler
    app_lock.wait()

  5. #5
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    54

    Re: left soft key

    Thanks for your help. Another doubt is related of the escaping of the parenthesis in text.
    Code:
    if index == 0:
            appuifw.app.body=appuifw.Text("E32USER-CBase (63)")
            appuifw.app.exit_key_handler=choise

  6. #6
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    54

    Re: left soft key

    With or without parentheses the selection list is not displayed at keypress.
    Last edited by Anime; 2009-02-23 at 21:14.

  7. #7
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    54

    Re: left soft key

    bind(event_code , callback) seem do not work for callback=choise (selection list)
    Code:
    canvas.bind(key_codes.EKeyLeftSoftkey, choise)
    Last edited by Anime; 2009-02-23 at 21:51.

  8. #8
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,777

    Re: left soft key

    Quote Originally Posted by Anime View Post
    bind(event_code , callback) seem do not work for callback=choise (selection list)
    Code:
    canvas.bind(key_codes.EKeyLeftSoftkey, choise)
    Hint: May be the use of lambda may help?
    Last edited by croozeus; 2009-02-24 at 09:50. Reason: corrected typo
    Pankaj Nathani
    www.croozeus.com

  9. #9
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    54

    Re: left soft key

    May be the use of lamda may help?
    Can you give an example, please?

  10. #10
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,777

    Re: left soft key

    Quote Originally Posted by Anime View Post
    Can you give an example, please?
    In your case,

    Code:
    canvas.bind(key_codes.EKeyLeftSoftkey, lambda: choise())
    Pankaj Nathani
    www.croozeus.com

  11. #11
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    54

    Re: left soft key

    Code:
    canvas.bind(key_codes.EKeyLeftSoftkey, lambda: choise())
    It seems not execute the selection list.
    Last edited by Anime; 2009-02-24 at 10:48.

  12. #12
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    54

    Re: left soft key

    How I set capturer.start() at every canvas callback?

Similar Threads

  1. Left and right soft key event
    By deepakgmi in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-08-22, 13:32
  2. Replies: 0
    Last Post: 2007-06-12, 08:39
  3. Replies: 2
    Last Post: 2005-09-03, 18:24
  4. Simulating left soft key, Pls look in to my code
    By alokkumarsingh in forum Symbian
    Replies: 4
    Last Post: 2004-07-05, 13:47
  5. Replies: 1
    Last Post: 2004-06-28, 09:57

Posting Permissions

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