Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Inline Editing: newline with alt + enter (Read 4469 times)
Freizeitsoldat
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: May 10th, 2009
Inline Editing: newline with alt + enter
Apr 19th, 2011 at 5:33pm
Print Post  
Hi Stoyo,

i would like to get a new line ("\n") while im pressing alt + enter during inline editing.

I tried to modify the key handlers in the beginEdit function, but inplaceTextArea.append("\n"); didnīt work.

Do you have an idea?

Thank you very much,
Alex
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Inline Editing: newline with alt + enter
Reply #1 - Apr 20th, 2011 at 6:10am
Print Post  
Hi Alex,

Handle enterInplaceEditMode and call e.getEditControl().addKeyListener() to add this keyTyped handler:

Code
Select All
public void keyTyped(KeyEvent e)
{
	if ((e.getModifiers() & KeyEvent.ALT_MASK) != 0 && e.getKeyChar() == '\n')
	{
		JTextArea textControl = (JTextArea)e.getComponent();
		textControl.insert("\n", textControl.getCaretPosition());
	}
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Freizeitsoldat
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: May 10th, 2009
Re: Inline Editing: newline with alt + enter
Reply #2 - Apr 20th, 2011 at 7:52am
Print Post  
Hi Stoyo,

i donīt exactly understand where i have to implement the keyTyped handler.

Perhaps i forgot to tell you, that iīm using jdiagram as an applet and i use jscript for interaction.

Thanks,
Alex
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Inline Editing: newline with alt + enter
Reply #3 - Apr 20th, 2011 at 8:14am
Print Post  
Tough luck, you can't implement a Java listener from JavaScript AFAIK. You could instead do this from your own applet that inherits from DiagramApplet:

Code
Select All
diagram.addDiagramListener(new DiagramAdapter() {
	public void enterInplaceEditMode(InPlaceEditEvent e)
	{
		e.getEditControl().addKeyListener(new KeyAdapter() {

			public void keyTyped(KeyEvent e)
			{
				if ((e.getModifiers() & KeyEvent.ALT_MASK) != 0 && e.getKeyChar() == '\n')
				{
					JTextArea textControl = (JTextArea)e.getComponent();
					textControl.insert("\n", textControl.getCaretPosition());
				}
			}

		});
	}
}); 



Or otherwise set InplaceEditAcceptOnEnter to false and the user will be able to use the Enter key for new lines, and end the edit operation with a click outside the text control.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Freizeitsoldat
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: May 10th, 2009
Re: Inline Editing: newline with alt + enter
Reply #4 - Apr 20th, 2011 at 8:33am
Print Post  
Hi Stoyo,

thank you for the answers.

I donīt know if itīs clear what i would like to implement:

I donīt want to change anything from javascript. I would like to add a keylistener directly in the java applet. I hoped to solve this within beginEdit() in the DiagramView class.

I donīt really understand what the addKeyListener function within beginEdit() does affect at all?

Thank you,
Alex
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Inline Editing: newline with alt + enter
Reply #5 - Apr 20th, 2011 at 9:42am
Print Post  
The sample code above is what you need then. When you call beginEdit(), that should raise the enterInplaceEditMode event, which you can handle as shown above. That's the only way to get access to the JTextArea used for inplace editing.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Inline Editing: newline with alt + enter
Reply #6 - Apr 20th, 2011 at 9:56am
Print Post  
If you mean you have the source code and are directly modifying the beginEdit method, then copy the keyTyped function to the block after this line -

inplaceTextArea.addKeyListener(new KeyAdapter(){
  
Back to top
 
IP Logged
 
Freizeitsoldat
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: May 10th, 2009
Re: Inline Editing: newline with alt + enter
Reply #7 - Apr 21st, 2011 at 12:11pm
Print Post  
Ahhhhg...

i did it exactly as you recommended before i asked you here in the forum...

It didnīt work because the jar builder didnīt work. That was the reason that i had no effect in the jdiagram.jar.

Thanks!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint