×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    101

    Binding modified key in Canvas

    I'd like to bind a modified key, such as ctrl+EKeyUpArrow, to a callback.

    I can bind a regular keypress with something like canvas.bind(key_codes.EKeyUpArrow, self.up_key_cb). Is there a simple modification to this line to detect modified keypresses?

    Or do I have to set event_callback in canvas and then examine all keypresses?

    In either event, if possible please provide an example, such as detecting ctrl+EKeyUpArrow or shift+something or func+something.

  2. #2
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Re: Binding modified key in Canvas

    I am almost sure you can't bind a combination of keys, but I think you can detect it using the event callback. See this quote from the documentation:

    event_callback is called whenever a raw key event is received or when a pointer event occurs(only on touch input supported devices). There are three kinds of key events: EEventKeyDown, EEventKey, and EEventKeyUp. When a user presses a key down, events EEventKeyDown and EEventKey are generated. When the key is released, an EEventKeyUp event is generated.

    Pointer events are generated by touch input supported devices. When the screen is touched the EButton1Down event is generated, EDrag while the finger/stylus is dragged across the screen and then EButton1Up when the finger/stylus is lifted.

    The argument to the event_callback is a dictionary that contains the following data:

    For key events:
    •'type': one of EEventKeyDown, EEventKey, or EEventKeyUp
    •'keycode': the keycode of the key
    •'scancode': the scancode of the key
    •'modifiers': the modifiers that apply to this key event
    So use ['modifiers'] for detection of those modifiers keys. Feel free to ask again if you have any kind of questions



    Hope this helps,

    Rafael.

  3. #3
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    101

    Re: Binding modified key in Canvas

    Quote Originally Posted by Rafael T. View Post
    I am almost sure you can't bind a combination of keys, but I think you can detect it using the event callback.
    My first issue is whether you can bind a combination of keys. You report that I can't, so I'll have to use an event callback. My major concern with the event callback is that it will slow performance to examine every keystroke.

    I had set up a simple test program to report on keycode, scancode, type and modifiers using an event_callback from canvas. Is there documentation on how to interpret the results? For example, exactly what does type mean? I noticed that holding down keys generated different results than quick keypresses.

    I suppose for these purposes I can just examine the keycode, scancode, type and modifiers of the keypress I want, but I'm interested in more detail.

Similar Threads

  1. Yucca please help: Long key press - iRepeats is never 1
    By Tasneem Rangwala in forum Symbian
    Replies: 1
    Last Post: 2009-10-28, 03:32
  2. List of Codes for Buttons
    By skela in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2008-05-20, 20:39
  3. Replies: 1
    Last Post: 2003-08-25, 11:22
  4. 7210 Canvas (MIDP) up/down key
    By rapix in forum Mobile Java General
    Replies: 2
    Last Post: 2003-07-30, 02:25
  5. Key Event Issues
    By mykes in forum Symbian
    Replies: 0
    Last Post: 2003-05-01, 10:55

Posting Permissions

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