Skip to main content


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 10:30 Go to next message
Thierry Monney is currently offline Thierry MonneyFriend
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 15:01 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
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 09:11 Go to previous messageGo to next message
Wojtek Jarosz is currently offline Wojtek JaroszFriend
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 08:42 Go to previous message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
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 - Red Hat
Senior Software Engineer in Fuse Tooling team
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 Apr 25 11:42:59 GMT 2024

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

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

Back to the top