How to check if a Text() is read only [message #551238] |
Thu, 05 August 2010 13:10  |
Eclipse User |
|
|
|
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 13:35   |
Eclipse User |
|
|
|
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 14:02  |
Eclipse User |
|
|
|
>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.
|
|
|
Powered by
FUDForum. Page generated in 0.04377 seconds