Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Setting a PtToggleButton that is part of a group: (4 Items)
   
Setting a PtToggleButton that is part of a group  
I have two PtToggleButtons

PtToggleButtonA
PtToggleButtonB

I wrote code to clear the screen and I am using this code to unset the toggle buttons.

PtSetResource(pWidget, Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);

This works as I expect when the two toggle buttons are not part of a group.  

I then made the two toggle buttons part of a group so that I could set them to be mutually exclusive.

Now, when my application launches, neither button is selected.  (As expected)
When the user selects one button, it deselects the other (As expected)
However, when my code runs to clear the screen (deselect both buttons) it no longer works.

What am I missing?

Any help is appreciated.  Thanks.
Re: Setting a PtToggleButton that is part of a group  
I have found a "work-around", but I hope there is a better, more direct way to accomplish this.

What I am currently doing is:

1. Calling PtGetResource() to determine if the exclusivity bit is set for the group.
2. If so, call PtSetResource() to turn the exclusivity off for the group.
3. Call PtSetResource() for the specific toggle button widget to clear it.
4. Call PtSetResource() for the group to turn exclusivity back on.

[CODE]
int clear(PtWidget_t* pWidget, PtWidget_t* pGroupWidget)
{ 
    short* pnBitVal = 0;
    char    bExclusiveBitSet = 0;

    //DETERMINE STATUS OF EXCLUSIVITY BIT
    PtGetResource(pGroupWidget, Pt_ARG_GROUP_FLAGS, &pnBitVal, Pt_GROUP_EXCLUSIVE);

    //STORE STATUS
    bExclusiveBitSet = (*pnBitVal) ? 1 : 0;
    
    //TURN OFF EXCLUSIVITY IF IT IS ON
    if(bExclusiveBitSet)
    {
        PtSetResource(pGroupWidget, Pt_ARG_GROUP_FLAGS, ~Pt_GROUP_EXCLUSIVE, Pt_GROUP_EXCLUSIVE);
    }

    //CLEAR Pt_SET FROM WIDGET
    PtSetResource(pWidget, Pt_ARG_FLAGS, ~Pt_SET, Pt_SET);

    //TURN EXCLUSIVITY BACK ON IF NECESSARY
    if(bExclusiveBitSet)
    {
        PtSetResource(pGroupWidget, Pt_ARG_GROUP_FLAGS, Pt_GROUP_EXCLUSIVE, Pt_GROUP_EXCLUSIVE);
    }

    return 0;
}
[/CODE]


Is there an easier or more direct way to do this?

Thanks,
Kendall

> I have two PtToggleButtons
> 
> PtToggleButtonA
> PtToggleButtonB
> 
> I wrote code to clear the screen and I am using this code to unset the toggle 
> buttons.
> 
> PtSetResource(pWidget, Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
> 
> This works as I expect when the two toggle buttons are not part of a group.  
> 
> I then made the two toggle buttons part of a group so that I could set them to
>  be mutually exclusive.
> 
> Now, when my application launches, neither button is selected.  (As expected)
> When the user selects one button, it deselects the other (As expected)
> However, when my code runs to clear the screen (deselect both buttons) it no 
> longer works.
> 
> What am I missing?
> 
> Any help is appreciated.  Thanks.


AW: Re: Setting a PtToggleButton that is part of a group  
Hi Kendall,

You need to set the flag  Pt_GROUP_NO_SELECT_ALLOWED  on the PtGroup widget.

Cheers,
Thomas

----- Originalnachricht -----
Von: Kendall Russell [mailto:community-noreply@qnx.com]
Gesendet: Thursday, June 09, 2011 04:13 PM
An: photon-graphics <post86539@community.qnx.com>
Betreff: Re: Setting a PtToggleButton that is part of a group

I have found a "work-around", but I hope there is a better, more direct way to accomplish this.

What I am currently doing is:

1. Calling PtGetResource() to determine if the exclusivity bit is set for the group.
2. If so, call PtSetResource() to turn the exclusivity off for the group.
3. Call PtSetResource() for the specific toggle button widget to clear it.
4. Call PtSetResource() for the group to turn exclusivity back on.

[CODE]
int clear(PtWidget_t* pWidget, PtWidget_t* pGroupWidget)
{ 
    short* pnBitVal = 0;
    char    bExclusiveBitSet = 0;

    //DETERMINE STATUS OF EXCLUSIVITY BIT
    PtGetResource(pGroupWidget, Pt_ARG_GROUP_FLAGS, &pnBitVal, Pt_GROUP_EXCLUSIVE);

    //STORE STATUS
    bExclusiveBitSet = (*pnBitVal) ? 1 : 0;
    
    //TURN OFF EXCLUSIVITY IF IT IS ON
    if(bExclusiveBitSet)
    {
        PtSetResource(pGroupWidget, Pt_ARG_GROUP_FLAGS, ~Pt_GROUP_EXCLUSIVE, Pt_GROUP_EXCLUSIVE);
    }

    //CLEAR Pt_SET FROM WIDGET
    PtSetResource(pWidget, Pt_ARG_FLAGS, ~Pt_SET, Pt_SET);

    //TURN EXCLUSIVITY BACK ON IF NECESSARY
    if(bExclusiveBitSet)
    {
        PtSetResource(pGroupWidget, Pt_ARG_GROUP_FLAGS, Pt_GROUP_EXCLUSIVE, Pt_GROUP_EXCLUSIVE);
    }

    return 0;
}
[/CODE]


Is there an easier or more direct way to do this?

Thanks,
Kendall

> I have two PtToggleButtons
> 
> PtToggleButtonA
> PtToggleButtonB
> 
> I wrote code to clear the screen and I am using this code to unset the toggle 
> buttons.
> 
> PtSetResource(pWidget, Pt_ARG_FLAGS, Pt_FALSE, Pt_SET);
> 
> This works as I expect when the two toggle buttons are not part of a group.  
> 
> I then made the two toggle buttons part of a group so that I could set them to
>  be mutually exclusive.
> 
> Now, when my application launches, neither button is selected.  (As expected)
> When the user selects one button, it deselects the other (As expected)
> However, when my code runs to clear the screen (deselect both buttons) it no 
> longer works.
> 
> What am I missing?
> 
> Any help is appreciated.  Thanks.






_______________________________________________

Photon microGUI
http://community.qnx.com/sf/go/post86539
Re: AW: Re: Setting a PtToggleButton that is part of a group  
Thank you.  That is exactly what I needed.