Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

KeyDown event for left and right arrow keys?

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
JohnSummit



Joined: 10 Apr 2008
Posts: 32

PostPosted: Thu Jun 25, 2009 7:08 am    Post subject: KeyDown event for left and right arrow keys? Reply with quote

I don't get any notifications when pressing the left and right keys. I do get notifications for the up and down keys.

I have multiple top-level items without children. I would like to have the up/down keys select the top-level items/ The left/right keys should be sent to my form so i can act on the selected tree item.

I am handling the virtualTreeSearchResults_KeyDown event.
Back to top
View user's profile Send private message
JohnSummit



Joined: 10 Apr 2008
Posts: 32

PostPosted: Thu Jun 25, 2009 7:12 am    Post subject: Reply with quote

To clarify: I do get the left/right arrow key events when no items exist in the tree. Once items are in the tree, the tree or form does not pass on the key down event.

I did try to do a this.KeyPreview = true; in the form constructor and handle the KeyDown event for the form but no event triggered. So it seems the form is to blame.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Jun 25, 2009 8:59 am    Post subject: Reply with quote

Arrow and tab keys are special (because they are used for navigation between controls) and are not passed to the KeyDown event. To handle arrow keys for a control you have override the ProcessCmdKey method. Since Virtual Tree handles a number of special navigation keys like arrow keys it overrides this method. The overridden method in turn calls methods ProcessLeftCmdKey, ProcessRightCmdKey etc to handle the different keys.

If you want to handle the arrow keys differently you need to derive a new control from Virtual Tree and override the ProcessLeftCmdKey and ProcessRightCmdKey methods eg.

Code:
    class MyTree : VirtualTree
    {
        protected override bool ProcessLeftCmdKey(System.Windows.Forms.Keys modifiers)
        {           
            return base.ProcessLeftCmdKey(modifiers);
        }
    }


Note that if you want the default Virtual Tree behaviour (in addition to your own) you will need to call the base class method.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group