Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic TextSelection in Box (Read 2220 times)
ampersand
Junior Member
**
Offline



Posts: 55
Joined: Sep 21st, 2006
TextSelection in Box
Nov 7th, 2006 at 8:58am
Print Post  
In my app I modified the behaviour of editing a Box. When the user selects a box and starts pressing keys, the box automatically switches to inplace editing mode.
Code
Select All
private void btChart_KeyPress(object sender, KeyPressEventArgs e)
{
  if (btChart.ActiveObject != null)
  {
    if (btChart.Selection.Objects.Count == 1)
    {
	if ((Char.IsLetterOrDigit(e.KeyChar)) || (Char.IsPunctuation(e.KeyChar)) ||
(Char.IsSeparator(e.KeyChar)) || (Char.IsSymbol(e.KeyChar)))
	{
	  if (btChart.ActiveObject.GetType() == typeof(Box))
	  {
	    (btChart.ActiveObject as Box).Text += e.KeyChar;
	    (btChart.ActiveObject as Box).BeginInplaceEdit();
	  }
	}
    }
  }
}
 



I now have the problem, that as soon as I press a key, and BeginInplaceEdit is called the text in the Box is selected and will be deleted if the user continues typing.

How can I prevent Box from selecting text, when BeginInplaceEdit is called or how can i deselect the text?

Is it possible to move the text cursor to a certain position in the text, let's say the end of the text? I couldn't find a function for it yet.

Thanks
Dirk
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TextSelection in Box
Reply #1 - Nov 7th, 2006 at 9:10am
Print Post  
Hi,

Handle the EnterInplaceEditMode event. It gives you a reference to the TextBox control used for editing. Use the TextBox methods to change the selection or move the cursor to the end.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
ampersand
Junior Member
**
Offline



Posts: 55
Joined: Sep 21st, 2006
Re: TextSelection in Box
Reply #2 - Nov 7th, 2006 at 11:16am
Print Post  
Thanks, that did the trick.

But I came over another issue. When I edit a Box and press ESC and immediately press a key afterwards it seems that the keyDown and Keypress event of the flowchart are not fired anymore. Only if I Click again on the same object (which is still the activeObject) the Key events are working again.

What am I doing wrong?

Dirk
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TextSelection in Box
Reply #3 - Nov 7th, 2006 at 11:26am
Print Post  
Perhaps the keyboard focus is not on the flowchart. Try calling the Control.Focus method from the LeaveInplaceEdit event handler.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint