See details here:
viewtopic.php?f=13&t=39270&start=0
Please add #PB_ListIcon_Unchecked constant
Re: Please add #PB_ListIcon_Unchecked constant
That would just add confusion, as the #PB_ListIcon_Checked is a 'flag' constant (combined with other values by | (bitwise or)). So the absence of the #PB_ListIcon_Checked indicates that the item is unchecked. There is no extra flag for that.
quidquid Latine dictum sit altum videtur
Re: Please add #PB_ListIcon_Unchecked constant
Thanks Freak, but actually I was thinking in terms of programmatically "unchecking" the checkbox later, after it had been previously checked.freak wrote:That would just add confusion, as the #PB_ListIcon_Checked is a 'flag' constant (combined with other values by | (bitwise or)). So the absence of the #PB_ListIcon_Checked indicates that the item is unchecked. There is no extra flag for that.
Re: Please add #PB_ListIcon_Unchecked constant
> Thanks Freak, but actually I was thinking in terms of programmatically "unchecking" the checkbox later, after it had been previously checked.
You do that by setting new flags that do not include the checked-flag. The absence of #PB_ListIcon_Checked causes the command to uncheck the checkbox. This is the way flag values (like gadget flags) work in other places too. (Yes i know #PB_Tree_Collapsed/#PB_Tree_Expanded is an exception but its more or less a hack and i regret having added that since a long time)
I assume you want this:But this code alters more than just the checked state. SetGadgetItemState() also checks for the presents of the #PB_ListIcon_Selected flag and sets/clears the selection accordingly. Since the value of #PB_ListIcon_Unchecked above does not include the selected flag, this command will clear the selection on every item you use it on and this is not what you would expect by looking at the call itself.
So we would need #PB_ListIcon_UncheckedAndSelected and #PB_ListIcon_UncheckedAndUnselected constants to be correct (and for every other flag that may be introduced in the future the list grows exponentially)
A second problem is that flags are tested for with the & operator (the GetGadgetItemState() manual describes that). If you have a pseudo-flag with the value 0 you have a problem, because a test like this will always fail:I can see the "bugreports" about that coming in already.
So you see, it does more harm than good by leading people into writing code that does not do what they expect it to do and thats a big problem.
You do that by setting new flags that do not include the checked-flag. The absence of #PB_ListIcon_Checked causes the command to uncheck the checkbox. This is the way flag values (like gadget flags) work in other places too. (Yes i know #PB_Tree_Collapsed/#PB_Tree_Expanded is an exception but its more or less a hack and i regret having added that since a long time)
I assume you want this:
Code: Select all
#PB_ListIcon_Unchecked = 0
SetGadgetItemState(#Gadget, item, #PB_ListIcon_Unchecked)
So we would need #PB_ListIcon_UncheckedAndSelected and #PB_ListIcon_UncheckedAndUnselected constants to be correct (and for every other flag that may be introduced in the future the list grows exponentially)
A second problem is that flags are tested for with the & operator (the GetGadgetItemState() manual describes that). If you have a pseudo-flag with the value 0 you have a problem, because a test like this will always fail:
Code: Select all
If GetGadgetItemState(...) & #PB_ListIcon_Unchecked
; do something
EndIf
So you see, it does more harm than good by leading people into writing code that does not do what they expect it to do and thats a big problem.
quidquid Latine dictum sit altum videtur
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Re: Please add #PB_ListIcon_Unchecked constant
so, what about
#PB_ListIcon_Clear

oh and while we are at naming Zeros...
I want a
#PB_Event_None

This is no joke, I'm serious.
PS:
I overlooked the arg with the check... you are right, this would create a mess.
but the Event_None is for checking a TimeOut properly...
#PB_ListIcon_Clear

oh and while we are at naming Zeros...
I want a
#PB_Event_None

This is no joke, I'm serious.
PS:
I overlooked the arg with the check... you are right, this would create a mess.
but the Event_None is for checking a TimeOut properly...
oh... and have a nice day.
Re: Please add #PB_ListIcon_Unchecked constant
Ah, I gotcha now.freak wrote:You do that by setting new flags that do not include the checked-flag. The absence of #PB_ListIcon_Checked causes the command to uncheck the checkbox. This is the way flag values (like gadget flags) work in other places too. (Yes i know #PB_Tree_Collapsed/#PB_Tree_Expanded is an exception but its more or less a hack and i regret having added that since a long time)
I agree. Maybe an short extra blurb in the doc or example on how to uncheck might help alleviate any confusion.freak wrote:So you see, it does more harm than good by leading people into writing code that does not do what they expect it to do and thats a big problem.
Thanks again