How to check if a Text() is read only [message #551238] |
Thu, 05 August 2010 17:10 |
Victor 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 |
Pascal G 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.*
|
|
|
|
Powered by
FUDForum. Page generated in 6.38506 seconds