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 

CTRL+A when row editing

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



Joined: 20 Nov 2007
Posts: 23
Location: Netherlands

PostPosted: Wed Jul 16, 2008 12:25 pm    Post subject: CTRL+A when row editing Reply with quote

I'd like to make CTRL+A select all text when there is an active editor (Textbox or universalEditBox) in a row. How can I do this?

I read this post:
http://www.infralution.com/phpBB2/viewtopic.php?t=962&highlight=processcmdkey

and noticed there is something like ProcessEditCmdKey (for handling key events when there is an active editor). I think I need this, but is there an example? I can't find out how to get the active editor and select the text.

Thanks a lot,
Anja
Back to top
View user's profile Send private message Visit poster's website
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Jul 16, 2008 11:15 pm    Post subject: Reply with quote

Yes you will need to override the ProcessEditCmdKeys method something like:

Code:
protected overrides bool ProcessEditCmdKeys(Keys keys)
{
    if (keys == Keys.Control | Keys.A)
    {
        SelectAllRows();
    }
    return base.ProcessEditCmdKeys(keys);
}


Note that the reason Virtual Tree doesn't implement this behaviour by default is that there can be a significant performance (and memory) penalty when selecting all rows. This is because this forces Virtual Tree to load the data for all the currently expanded rows. If you have a very large number of rows in any given level (eg 100000 rows beneath the root row) then this could take considerable time.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
AB



Joined: 20 Nov 2007
Posts: 23
Location: Netherlands

PostPosted: Thu Jul 17, 2008 6:27 pm    Post subject: Reply with quote

Well, this is not exactly what I meant. I'd like to select the text (all the words) which has been entered in a textbox cell in the tree, not all rows in the tree. So when I override the ProcessEditCmdKeys method, how can I detect which cell is being editted and how can I get to the textbox to select the text, when it is in edit mode?
Back to top
View user's profile Send private message Visit poster's website
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Jul 17, 2008 11:12 pm    Post subject: Reply with quote

Sorry I misunderstood you. The problem is that the standard TextBox does not handle the Control-A combination. You can derive your own TextBox control that does as follows:

Code:
    public class MyTextBox : TextBox
    {
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == (Keys.A | Keys.Control))
            {
                this.SelectAll();
                return true;
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }
    }


You can then use this as your editor.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
AB



Joined: 20 Nov 2007
Posts: 23
Location: Netherlands

PostPosted: Mon Jul 21, 2008 2:19 pm    Post subject: Reply with quote

Yes, that's what I was looking for. Is it also possible to do something similar with a UniversalEditBox instead of a TextBox?
Back to top
View user's profile Send private message Visit poster's website
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Jul 21, 2008 10:31 pm    Post subject: Reply with quote

Yes but to select the text you have to call the internal TextBox property eg

Code:
    public class MyUniversalEditBox : UniversalEditBox
    {
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == (Keys.A | Keys.Control))
            {
                this.TextBox.SelectAll();
                return true;
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }
    }

_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
AB



Joined: 20 Nov 2007
Posts: 23
Location: Netherlands

PostPosted: Tue Jul 22, 2008 8:25 am    Post subject: Reply with quote

Thank you very much, great support again!
Back to top
View user's profile Send private message Visit poster's website
Advansys



Joined: 27 May 2011
Posts: 20

PostPosted: Mon May 26, 2014 8:28 am    Post subject: Reply with quote

Would you recommend this same approach to enable the Ctrl+Left and Ctrl+Right arrows?

Our objective is to have the textbox edit function in the same way as editing a file name in Windows File Explorer, i.e. being able to move the cursor by word, left or right.

If it is the same approach, how should we send the Ctrl+Left or Ctrl+Right to the textbox after we trap it using the keyData test?

We also want to have the Tab key save changes and exit edit mode.

Thank for any advice you can offer.

Regards,

Greg
Advansys
Back to top
View user's profile Send private message Visit poster's website
Advansys



Joined: 27 May 2011
Posts: 20

PostPosted: Mon May 26, 2014 9:21 am    Post subject: Reply with quote

Sorry, I see you have already answered the same question here: http://www.infralution.com/phpBB2/viewtopic.php?p=9540#9540. Sorry for the duplication.

Thanks!
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