Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - PhAB: need help on exclusive toggle pushing button : (4 Items)
   
PhAB: need help on exclusive toggle pushing button  
Hi,

I have a Photon application with three exclusive chosen options. 
My window need three push buttons to select each option. 
When user push a button, it must be "set" and all other are "unset". If one of them is set before, it must be unset.

How can I do ? I have set Pt_TOGGLE bit but it just "set" itseft and do not "unset" all other ones.


Attachment: Image toggle_button.png 1.33 KB
Re: PhAB: need help on exclusive toggle pushing button  
Hi Cong,

You can use something like the following callback function for all three buttons:

---
int
ButtonSet( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )

    {

    PtArg_t   arg[1];
    /* eliminate 'unreferenced' warnings */
    widget = widget, apinfo = apinfo, cbinfo = cbinfo;
    
    if( widget == ABW_PtButton1 ){
        PtSetArg( &arg[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET );
        PtSetResources( ABW_PtButton1, 1, &arg[0] );
        PtSetArg( &arg[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET );
        PtSetResources( ABW_PtButton2, 1, &arg[0] );
        PtSetArg( &arg[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET );
        PtSetResources( ABW_PtButton3, 1, &arg[0] );
    } else if ( widget == ABW_PtButton2 ){
        PtSetArg( &arg[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET );
        PtSetResources( ABW_PtButton1, 1, &arg[0] );
        PtSetArg( &arg[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET );
        PtSetResources( ABW_PtButton2, 1, &arg[0] );
        PtSetArg( &arg[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET );
        PtSetResources( ABW_PtButton3, 1, &arg[0] );
    } else if ( widget == ABW_PtButton3 ){
        PtSetArg( &arg[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET );
        PtSetResources( ABW_PtButton1, 1, &arg[0] );
        PtSetArg( &arg[0], Pt_ARG_FLAGS, Pt_FALSE, Pt_SET );
        PtSetResources( ABW_PtButton2, 1, &arg[0] );
        PtSetArg( &arg[0], Pt_ARG_FLAGS, Pt_TRUE, Pt_SET );
        PtSetResources( ABW_PtButton3, 1, &arg[0] );
    }
    
    return( Pt_CONTINUE );

    }
---

Pt_TOGGLE should be set for all three buttons.

Respectfully,
Oleg

11 июля 2018 г., в 12:59, Cong Pham <community-noreply@qnx.com> написал:

> Hi,
> 
> I have a Photon application with three exclusive chosen options. 
> My window need three push buttons to select each option. 
> When user push a button, it must be "set" and all other are "unset". If one of them is set before, it must be unset.
> 
> How can I do ? I have set Pt_TOGGLE bit but it just "set" itseft and do not "unset" all other ones.
> 
> 
> 
> 
> 
> 
> _______________________________________________
> 
> QNX4 Community Support
> http://community.qnx.com/sf/go/post118937
> To cancel your subscription to this discussion, please e-mail qnx4-community-unsubscribe@community.qnx.com
> <toggle_button.png>

Re: PhAB: need help on exclusive toggle pushing button  
Alternatively, you can try placing toggle buttons in a group (PtGroup) with Pt_GROUP_EXCLUSIVE set
Re: PhAB: need help on exclusive toggle pushing button  
Hi,
Thank Mr Oleg Bolshakov and Mr Alexander Koppel for suggesting me.

I have used PtGroup and it worked fine.