Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User bakidilek's Avatar
    Join Date
    Nov 2007
    Posts
    34
    I want to learn more key handling without using event_callback.I have already checked keys_example.py and ex_use_of_keys_descr.py in mobilenin.com but I didn't understand anything. examples are too complex for me.can anybody explain key handling in a simplest way please?




    thanks

  2. #2
    Nokia Developer Moderator bogdan.galiceanu's Avatar
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471
    The easiest way to handle key events is using the keycapture module. I suggest you read about it in the PyS60 Library Reference. Basically you just define functions that are called when a specific key is pressed.

    Here is an example:
    Code:
    import keycapture, appuifw, e32
    
    
    def cb_capture(key):
    	if(key==keycapture.EKeyLeftSoftkey):
    		print "Left softkey pressed"
    	elif(key==keycapture.EKeyRightSoftkey):
    		print "Right softkey pressed"
    		capturer.stop()
    		app_lock.signal()
    
    capturer=keycapture.KeyCapturer(cb_capture)
    capturer.keys=([keycapture.EKeyLeftSoftkey, keycapture.EKeyRightSoftkey])
    
    capturer.start()
    
    app_lock=e32.Ao_lock()
    app_lock.wait()
    Last edited by bogdan.galiceanu; 2009-01-02 at 11:39.

  3. #3
    Nokia Developer Champion gaba88's Avatar
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,692
    hello bakidilek

    just to add a bit in bogdans post you can also have a look at this article if it helps you.

    Enjoy Pythoning
    Gaba88

  4. #4
    Registered User bakidilek's Avatar
    Join Date
    Nov 2007
    Posts
    34
    thanks for your replies.I know the keycapture module, keycapture module can handle keys even the app is running in background but I dont want to handle key when the app is running in background.and I know the canvas.bind method but I dont want to use canvas handling hethod too.I want to understand this code: http://www.mobilenin.com/pys60/resou...use_of_keys.py

    can you explain it please?

    thanks again and soryy about my English

  5. #5
    Registered User igordsm's Avatar
    Join Date
    Jul 2008
    Posts
    65
    That code uses the Canvas method to get events. It simply created a Keyboard class that has a dictionary with the scancode of pressed keys. Then it assigned the method handle_event of a keyboard instance to the Canvas event_callback argument and made a app loop that shows a note if the desired key is pressed.

    Is it clear?
    http://igordsm.googlepages.com

Similar Threads

  1. volume key event handling
    By whitewinds in forum Symbian Media (Closed)
    Replies: 4
    Last Post: 2009-05-13, 04:01
  2. Help me for touch Screen Event Handling
    By nil.bagul in forum Mobile Java General
    Replies: 1
    Last Post: 2008-03-28, 11:22
  3. A question about multiple views and key event handling
    By EeroS in forum Symbian User Interface
    Replies: 2
    Last Post: 2007-07-13, 09:35
  4. Info. abt. handling Key Event
    By netra in forum Symbian C++
    Replies: 2
    Last Post: 2007-06-27, 12:21
  5. Replies: 1
    Last Post: 2003-08-25, 11:22

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