Why I can't detect if left softkey is clicked just like other keys?
Why I can't detect if left softkey is clicked just like other keys?
I think you can, using the keycapture module. See this thread (although rather old) for a discussion about it.
Here's 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:41.
There is no it intercepts pressing and in the menu though so it will turn out very much it will be not convenient. Here so I do
It is the best variant but it is necessary to work with graphicsCode:import appuifw,e32,graphics body=graphics.Image.new((176,208)) def keys(x): if x['type']==3: if x['scancode']==164: body.text((50,80),u'button pressed',0x0000ff,font=u'Alb17b') canvas.blit(body) appuifw.app.body=canvas=appuifw.Canvas(event_callback=keys) body.clear(0xff0000) canvas.blit(body) e32.Ao_lock().wait()
Thank you so much bogdan.galiceanu and Versoul. Versoul's solution is perfect for me.
BTW is that x['type']==3 same as x['type']==appuifw.EEventKey ?
DrivingMobileInnovation: its mean x['type']==appuifw.EEventKeyDown
Without it the code of function will be called out 2 times by pressing and unpressing key
EEventKey = 1
EEventKeyUp = 2
Last edited by Versoul; 2008-06-20 at 21:43.