Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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,
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: Tue Jul 22 23:49:18 EDT 2025

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

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

Back to the top