Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Hide caret in Text widget
Hide caret in Text widget [message #435101] Fri, 23 April 2004 06:30 Go to next message
Thierry Monney is currently offline Thierry Monney
Messages: 10
Registered: July 2009
Junior Member
Hi group !

I was wondering how to hide the caret in a text widget. I already tried
to get it with
text.getShell().getCaret();
but this one returns null. I already tried to create a caret:
Caret caret = new Caret(text, SWT.NONE);
caret.setVisible(false);

I problably missed something... Is there a simple way to do it ?

Thanks in advance

Thierry
Re: Hide caret in Text widget [message #435161 is a reply to message #435101] Fri, 23 April 2004 11:01 Go to previous messageGo to next message
Steve Northover is currently offline Steve Northover
Messages: 1636
Registered: July 2009
Senior Member
You can't. The caret is shown and hidden by the text widget based on
platform conventions.

"Thierry Monney" <titi-r5@bluewin.ch> wrote in message
news:c6aqtl$cnp$1@eclipse.org...
> Hi group !
>
> I was wondering how to hide the caret in a text widget. I already tried
> to get it with
> text.getShell().getCaret();
> but this one returns null. I already tried to create a caret:
> Caret caret = new Caret(text, SWT.NONE);
> caret.setVisible(false);
>
> I problably missed something... Is there a simple way to do it ?
>
> Thanks in advance
>
> Thierry
Re: Hide caret in Text widget [message #1059198 is a reply to message #435161] Fri, 17 May 2013 05:11 Go to previous messageGo to next message
Wojtek Jarosz is currently offline Wojtek Jarosz
Messages: 4
Registered: May 2013
Junior Member
I know this is a very old question, but perhaps it will still be useful to reply, as people are searching for answers all the time. I recently had the same problem and yes, you can disable the caret! At least you can, if you are happy changing your text widget to be StyledText. Then you simply do:
text.setCaret(null);
and all is well, as if by magic Smile No need to get at shells no need to get the Caret object and the change affects only the specified field.
Hope it helps.
Wojtek
See also the article "Demos and Usage of org.eclipse.swt.custom.StyledText.setCaret(Caret caret)" at www.javadocexamples.com/org/eclipse/swt/custom/StyledText
Re: Hide caret in Text widget [message #1060717 is a reply to message #435101] Tue, 28 May 2013 04:42 Go to previous message
Aurelien Pupier is currently offline Aurelien Pupier
Messages: 558
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi,

seems to be still a subject of discussion and I didn't found an acceptable solution for me.

I can't use StyledWidget for various reason so I searched for another way and here it is:
The caret is still visible only on Windows after setting a read-only on the Text. So I use a win32 fragment specific providing a FocusListener which is calling org.eclipse.swt.internal.win32.OS.DestroyCaret() on focusGained.

Please note that I'm clearly not very happy with this solution so if someone else have another better solution, he is very welcome to provide it.

Regards,


Aurélien Pupier - BonitaSoft S.A.
My blog
My company Eclipse-related blog
Previous Topic:How to keep Popup-menu open after selection event?
Next Topic:How to detect that code is running in Development environment or in generic Eclipse using Plugins?
Goto Forum:
  


Current Time: Thu Aug 21 06:30:59 EDT 2014

Powered by FUDForum. Page generated in 0.02944 seconds