What is the best way to update the FXToggleButton icon?

View: New views
2 Messages — Rating Filter:   Alert me  

What is the best way to update the FXToggleButton icon?

by Feng Feng :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all,

I have a FXToggleButton button and need to change its icon based on whether it is pressed or unpressed..

Can I do it in the update function as follows?
FXMAPFUNC(SEL_UPDATE, XXX::ID_BUTTON1, XXX::OnUpdateButton1),

XXX::OnUpdateButton1(...)
{
    if (pressed)
      button1->setIcon(icon1);
    else
      button1->setIcon(icon2);
   ...
}

Thank  you



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Foxgui-users mailing list
Foxgui-users@...
https://lists.sourceforge.net/lists/listinfo/foxgui-users

Re: What is the best way to update the FXToggleButton icon?

by Jeroen van der Zijp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tuesday 01 September 2009, Feng Feng wrote:

> Hello all,
>
> I have a FXToggleButton button and need to change its icon based on whether it is pressed or unpressed.
>
> Can I do it in the update function as follows?
> FXMAPFUNC(SEL_UPDATE, XXX::ID_BUTTON1, XXX::OnUpdateButton1),
>
> XXX::OnUpdateButton1(..)
> {
>     if (pressed)
>       button1->setIcon(icon1);
>     else
>       button1->setIcon(icon2);
>    ...
> }

Yes, that would totally work...

If the update handler doesn't know what widget sent the SEL_UPDATE, you could also
use the ID_SETICONVALUE message and set the icon that way [its simply ignored if
the widget doesn't understand it].

The method you've chosen is optimal if the widget that issues the message is known,
however.

Small note: when your GUI starts up, only one of the two icons is liable to be set.
Thus, somewhere you may have to call create() on the other one, since the not-yet-set
icon is not referenced from the widget tree it isn't automatically created when the
widget tree is.


        Cheers,

                                - Jeroen

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Foxgui-users mailing list
Foxgui-users@...
https://lists.sourceforge.net/lists/listinfo/foxgui-users