Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Catching key pressing
Catching key pressing [message #458875] Mon, 25 July 2005 14:11 Go to next message
Alex is currently offline AlexFriend
Messages: 65
Registered: July 2009
Member
Hello. Please, tell me, how can I catch Enter key pressing in my
TextEditor class? I'm try to add auto indent to my editor.
Re: Catching key pressing [message #458891 is a reply to message #458875] Mon, 25 July 2005 16:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Alex" <rashevsky@gmail.com> wrote in message
news:651a2d9a2f7a7db70288b1ff9c24299e$1@www.eclipse.org...
> Hello. Please, tell me, how can I catch Enter key pressing in my
> TextEditor class? I'm try to add auto indent to my editor.
>
>
To add auto indent, you don't need to catch key presses yourself.
Consider using the org.eclipse.jface.text.IAutoEditStrategy interface
instead.
Specifically, you could extend
org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy
(org.eclipse.jface.text.DefaultAutoIndentStrategy in Eclipse 3.0).
You can then call prependAutoEditStrategy() on your TextViewer to install
your strategy.
---
Sunil
Re: Catching key pressing [message #458910 is a reply to message #458891] Tue, 26 July 2005 10:21 Go to previous messageGo to next message
Alex is currently offline AlexFriend
Messages: 65
Registered: July 2009
Member
Tnx.
So, I wrote XMLAutoIndentStrategy class, register it in the
XMLSourceViewerConfiguration class:
public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer
sourceViewer,
String contentType)
{
return new
XMLAutoIndentStrategy(UIPlugin.getDefault().getPreferenceSto re());
}

Then, I set configuration in the Editor class:
setSourceViewerConfiguration(new XMLConfiguration(colorManager));

But when I press "Enter" key method
XMLAutoIndentStrategy.customizeDocumentCommand does'n calls...

Sorry for my english...
Re: Catching key pressing [message #458925 is a reply to message #458910] Tue, 26 July 2005 17:05 Go to previous message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Alex" <rashevsky@gmail.com> wrote in message
news:bc7296c2153a2994745037ace78c6597$1@www.eclipse.org...
> Tnx.
> So, I wrote XMLAutoIndentStrategy class, register it in the
> XMLSourceViewerConfiguration class:
> public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer
> sourceViewer,
> String contentType)
> {
> return new
> XMLAutoIndentStrategy(UIPlugin.getDefault().getPreferenceSto re());
> }
>
> Then, I set configuration in the Editor class:
> setSourceViewerConfiguration(new XMLConfiguration(colorManager));
>
> But when I press "Enter" key method
> XMLAutoIndentStrategy.customizeDocumentCommand does'n calls...
>
> Sorry for my english...
>

Have you set up document partitioning?
Without document partitioning, auto indent will not work.
If you have, then all I can recommend is debugging to make sure your auto
indent strategy is being installed, and then check what happens when a key
is pressed on the editor styledtext widget.
---
Sunil
Previous Topic:Table (Item) color for selected state.
Next Topic:Problem with SWT_AWT and JOptionPane
Goto Forum:
  


Current Time: Thu Apr 25 14:48:31 GMT 2024

Powered by FUDForum. Page generated in 0.03120 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top