Overriding OnKeyDown

8 posts, 0 answers
  1. Andrea
    Andrea avatar
    16 posts
    Member since:
    Jul 2012

    Posted 29 Apr 2014 Link to this post

    Hi,

    We are using numeric up downs in a grid, but we do not want the up and down keys to change the value as we would like to preserve them for navigating around the grid. Previously, we were able to do this by overriding the OnKeyDown event. Since updating to 2014.1.224 from 2013.2.0611, this no longer works. I've compared the two binaries with reflector and it looks like the signature of the OnKeyDown event has changed from OnKeyDown(KeyEventsArgs e) to OnKeyDown(object sender, KeyEventsArgs e). We are unable to override this new event, and therefore the base one is always firing.

    Can you provide a workaround please?

    Thanks,
    Andrea
  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 30 Apr 2014 Link to this post

    Hello Andrea,

    The change is the following - we are no longer overriding the OnKeyDown of the TextBox inside the NumericUpDown, but hooking to the event. So, I would suggest you to do the same.
    Please give it a try and let us know if this is working for you.

    Regards,
    Konstantina
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. DevCraft banner
  4. Andrea
    Andrea avatar
    16 posts
    Member since:
    Jul 2012

    Posted 01 May 2014 in reply to Konstantina Link to this post

    Hi Konstantina,

    Thanks for getting back to me. However, that didn't work. It looks like the RadNumericUpDown class attaches to the evfent handler like this:

    base.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(this.OnKeyDown), true);


    The last argument to AddHandler is described as follows:
     
    handledEventsToo
    Type: System.Boolean
    true to register the handler such that it is invoked even when the routed event is marked handled in its event data; false to register the handler with the default condition that it will not be invoked if the routed event is already marked handled.
    The default is false.
    Do not routinely ask to rehandle a routed event. For more information, see Remarks

    Even if I set Handled = true in my event handler, it won't stop your handler from running.

    Any ideas?
    Thanks,
    Andrea

  5. Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 06 May 2014 Link to this post

    Hi Andrea,

    We understand your concern. However we will need additional time to research for a proper solution. We will get back to you as soon as possible.

    Thanks for the understanding.

    Regards,
    Kalin
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  6. Andrea
    Andrea avatar
    16 posts
    Member since:
    Jul 2012

    Posted 06 May 2014 in reply to Kalin Link to this post

    Hi Kalin,

    Thanks for getting back to me. Are you able to advise of any timescales? Does it help if I log this as a support ticket?

    Thanks,
    Andrea
  7. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 08 May 2014 Link to this post

    Hello Andrea,

    Thank you for your patience.

    We have thoroughly researched the possibility of changing this behavior, but that will break the already fixed bug. However, I am sending you a sample application in which I have proposed a work-around to achieve the desired behavior.

    Hope it helps.

    Regards,
    Konstantina
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  8. Andrea
    Andrea avatar
    16 posts
    Member since:
    Jul 2012

    Posted 13 May 2014 in reply to Konstantina Link to this post

    Hi Kalin,
    Thanks! However, I haven't received the sample application? Were you going to attach it to your post or am I just being blind and not seeing it?

    Thanks,
    Andrea
  9. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 13 May 2014 Link to this post

    Hi Andrea,

    Sorry, there was a problem with the post.
    I have attached it to the previous post. Please download it and give it a try.

    Regards,
    Konstantina
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top
DevCraft banner