Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » How to check if a Text() is read only
How to check if a Text() is read only [message #551238] Thu, 05 August 2010 17:10 Go to next message
Victor  is currently offline Victor Friend
Messages: 16
Registered: June 2010
Junior Member
Hi all,
I want to check if a text box is read only, in other words, if it is not editable.
I am trying to use this:

bot.text().isEnable();

But, even if the text is not editable, this method returns true.
Then, to check it out, I tried this:

bot.text().setText("just a test");

And, for my surprise, the string "just a text" was inserted in the text box.

So, how can I check if this text box is not editable? And SWTBot can edit fields that are not editable?

Thanks in advance

Victor
Re: How to check if a Text() is read only [message #551252 is a reply to message #551238] Thu, 05 August 2010 17:35 Go to previous messageGo to next message
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
On 10-08-05 01:10 PM, Victor wrote:
> Hi all,
> I want to check if a text box is read only, in other words, if it is not
> editable.
> I am trying to use this:
>
> bot.text().isEnable();
>
> But, even if the text is not editable, this method returns true.
> Then, to check it out, I tried this:
>
> bot.text().setText("just a test");
>
> And, for my surprise, the string "just a text" was inserted in the text
> box.
>
> So, how can I check if this text box is not editable? And SWTBot can
> edit fields that are not editable?
>
> Thanks in advance
>
> Victor

Hmmm, I believe a method isReadOnly() would be a nice addition to
SWTBotText API, but for now, you can do:

SWTUtils.hasStyle(bot.text().widget, SWT.READ_ONLY);

> And SWTBot can
> edit fields that are not editable?

The style READ_ONLY on a Text does not prevent you from programmatically
setting its text (otherwise how would UI programmer do to set the text
of a Text widget??). And that's what setText() does. If you had used
typeText() instead, it would not have setted the text.

(wow, too many "text" in this paragraph...)

Hope this helps.
--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Re: How to check if a Text() is read only [message #551258 is a reply to message #551252] Thu, 05 August 2010 18:02 Go to previous message
Victor  is currently offline Victor Friend
Messages: 16
Registered: June 2010
Junior Member
>Hmmm, I believe a method isReadOnly() would be a nice >addition to
>SWTBotText API, but for now, you can do:
>SWTUtils.hasStyle(bot.text().widget, SWT.READ_ONLY);

It worked fine. Thanks a lot.

>The style READ_ONLY on a Text does not prevent you from >programmatically
>setting its text (otherwise how would UI programmer do to set the >text
>of a Text widget??). And that's what setText() does. If you had used
>typeText() instead, it would not have setted the text.

Looking from that perspective, it really makes sense. hehehe.

Thanks a lot again.
Previous Topic:SWTBot source repository
Next Topic:Problem clicking popup menu (stays visible)
Goto Forum:
  


Current Time: Fri Apr 26 16:07:24 GMT 2024

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

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

Back to the top