Overriding the Key Up and Key down events in RadComboBox

7 posts, 0 answers
  1. Sajeev
    Sajeev avatar
    3 posts
    Member since:
    May 2011

    Posted 05 Aug 2011 Link to this post

    Hi,

    Have a requirement where the combobox should behave differently to Key up and Key down events when in dropdown open and dropdown closed modes.

    I need when the dropdown is closed and the text is focused, the key up and key down event should not move to next item in the drop down list, instead just post an event which will be used by another module. In case of when the dropdown is in opened state, the key up/key down should move on the items on the list.

    Am using MVVM pattern, but catching the key events in code behind.

    Is this possible???

    Sajeev
  2. Sajeev
    Sajeev avatar
    3 posts
    Member since:
    May 2011

    Posted 06 Aug 2011 Link to this post

    Possibly can be achieved using Triggers. Need to check.
  3. DevCraft banner
  4. Jason
    Jason avatar
    30 posts
    Member since:
    May 2009

    Posted 11 Aug 2011 Link to this post

    I have the same need.  I need to disable the default handling of Up and Down so that it doesnt move the item and another piece can know when up and down are hit.  But if the dropdown is open i want up and down to maintain their current ability.

    I decompiled the code and it looks like all of the key handling methods are private or protected internal virtual and the handler is added via AddHandler with true as the last parameter to always process no matter what.

    Therefore i cannot see a way to override the default processing of keys but this is a feature that we really need.
  5. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 15 Aug 2011 Link to this post

    Hello,

    You could override the virtual protected internal method HandleKeyDown and call base when the key is not Up/Down.

    Greetings,
    Valeri Hristov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  6. Jason
    Jason avatar
    30 posts
    Member since:
    May 2009

    Posted 15 Aug 2011 Link to this post

    internal means it can only be seen from the same assembly, so no we cannot override that method.  If the internal keyword were not there and it was just protected then yes we could do what we need to
  7. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 15 Aug 2011 Link to this post

    internal protected means internal OR protected, e.g. public in the same assembly, protected in the other assemblies:
    http://msdn.microsoft.com/en-us/library/ms173121.aspx

    It works, believe me :)

    Greetings,
    Valeri Hristov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  8. Jason
    Jason avatar
    30 posts
    Member since:
    May 2009

    Posted 15 Aug 2011 Link to this post

    oh cool, having never used protected internal before and assuming what it meant i thought you would only be able to override from class in the same assembly.  cool this will work then

    Thanks
Back to Top
DevCraft banner