Skip to main content



      Home
Home » Eclipse Projects » SWTBot » Toggle Button isn't checked
Toggle Button isn't checked [message #41989] Tue, 07 July 2009 05:46 Go to next message
Eclipse UserFriend
Hi everyone,

I’m new to SWTBot and I’m trying to test an RCP application.
The application has a toogle-button in a coolbar.
I’m able to find the widget and performe a click() on it:

bot.viewByTitle("title").toolbarButton("tooltip").click();

But I don’t get it working that the toggle-button is checked after the
click.

My application checks if button.isChecked() and if not it won’t work as
expected.

I searched the web and the newsgroup and found, that toggle-buttons are
supported by SWTBot according to
https://bugs.eclipse.org/bugs/show_bug.cgi?id=269919

I’m running the latest nightly build of SWTBot.

What do you think is my fault?

Thank you
Benjamin
Re: Toggle Button isn't checked [message #42116 is a reply to message #41989] Tue, 07 July 2009 14:15 Go to previous messageGo to next message
Eclipse UserFriend
Benjamin Glaser wrote:


> bot.viewByTitle("title").toolbarButton("tooltip").click();



To select checkboxes I have used:

bot.checkBox("Title").select();

and similarly to uncheck the checkbox:

bot.checkBox("Title").deselect();



~Derek
Re: Toggle Button isn't checked [message #42147 is a reply to message #42116] Tue, 07 July 2009 14:22 Go to previous messageGo to next message
Eclipse UserFriend
Derek wrote:

> Benjamin Glaser wrote:


>> bot.viewByTitle("title").toolbarButton("tooltip").click();



> To select checkboxes I have used:

> bot.checkBox("Title").select();

> and similarly to uncheck the checkbox:

> bot.checkBox("Title").deselect();


Oops, I don't think I read that enough. I saw you say something about
"Toggle" and instantly thought of a checkbox.

For toolbar I've just used:

bot.toolbarButton("ButtonTitle").click();


~Derek
Re: Toggle Button isn't checked [message #42234 is a reply to message #42147] Wed, 08 July 2009 02:49 Go to previous messageGo to next message
Eclipse UserFriend
> For toolbar I've just used:
> bot.toolbarButton("ButtonTitle").click();
> ~Derek

Hi Derek,

thanks for your fast reply.

Your suggestion is almont the same way I tried to handle it.
xxx.click() works so far for me, that it does perform a click.

But that click don't sets the toggle-button-state to "checked", as a
normal mouseclick by an user does.

It would be great if SWTBot sets the toggleButton to checked after it as
been clicked, but in my case it won't work.

Any suggestions?

Benjamin
Re: Toggle Button isn't checked [message #42271 is a reply to message #42234] Wed, 08 July 2009 06:54 Go to previous messageGo to next message
Eclipse UserFriend
Please file a bug, and I'll take a look at it. It would be great if you
could submit a patch for doing so. You may look at an existing
SWTBotToolbarButton implementation on how this is done.

--
Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr

On 8/7/09 12:19, Benjamin Glaser wrote:
>> For toolbar I've just used:
>> bot.toolbarButton("ButtonTitle").click();
>> ~Derek
>
> Hi Derek,
>
> thanks for your fast reply.
>
> Your suggestion is almont the same way I tried to handle it.
> xxx.click() works so far for me, that it does perform a click.
>
> But that click don't sets the toggle-button-state to "checked", as a
> normal mouseclick by an user does.
>
> It would be great if SWTBot sets the toggleButton to checked after it as
> been clicked, but in my case it won't work.
>
> Any suggestions?
>
> Benjamin
>
>
>
>
Re: Toggle Button isn't checked [message #42295 is a reply to message #42271] Wed, 08 July 2009 08:18 Go to previous messageGo to next message
Eclipse UserFriend
Ketan Padegaonkar wrote:
> Please file a bug, and I'll take a look at it. It would be great if you
> could submit a patch for doing so. You may look at an existing
> SWTBotToolbarButton implementation on how this is done.
>

Maybe a solution would be to make the click() method use the
Display.post()? Or maybe give an API to leave the choice to the
programmer, such as click(boolean)? Then you wouldn't even need to
replicate the behavior of the button(s).

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

*Because performance matters.*
Re: Toggle Button isn't checked [message #42500 is a reply to message #42271] Thu, 09 July 2009 05:11 Go to previous messageGo to next message
Eclipse UserFriend
I made a bug report:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=282982

I hope I described it enough.

What else can I do?

Benjamin
Re: Toggle Button isn't checked [message #43394 is a reply to message #42500] Tue, 14 July 2009 05:21 Go to previous message
Eclipse UserFriend
Hi Ketan,

thanks again for the quick bug fixing.
But it doesn't solve my issue completely.

I looked at the sourcecode you implemented:

notify(SWT.MouseEnter);
notify(SWT.MouseMove);
notify(SWT.Activate);
notify(SWT.MouseDown); //think this does the actual click
notify(SWT.MouseUp);
notify(SWT.Selection);
notify(SWT.MouseHover);
notify(SWT.MouseMove);
notify(SWT.MouseExit);
notify(SWT.Deactivate);
notify(SWT.FocusOut);
internalToggle(); // sets the button-state to checked

If I click on a button, the run() methode which is definied for this
button is called. This methode checks the state of the button.
But the state wasn't changed at this moment because it is changed after
the actual click.

I would recommend to do the internalToggle() before the notify(...).
I changed it in my code and now it works for me.
I think it would be helpful for other users too.

What do you think?

Benjamin
Previous Topic:Custom Widgets
Next Topic:CTabItem
Goto Forum:
  


Current Time: Sat Jun 21 20:21:09 EDT 2025

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

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

Back to the top