Page 1 of 1
Please add #PB_ListIcon_Unchecked constant
Posted: Mon Sep 28, 2009 6:33 pm
by USCode
Re: Please add #PB_ListIcon_Unchecked constant
Posted: Mon Sep 28, 2009 7:50 pm
by freak
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
Posted: Mon Sep 28, 2009 10:35 pm
by USCode
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.
Thanks Freak, but actually I was thinking in terms of programmatically "unchecking" the checkbox later, after it had been previously checked.
Re: Please add #PB_ListIcon_Unchecked constant
Posted: Tue Sep 29, 2009 12:21 am
by freak
> 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:
Code: Select all
#PB_ListIcon_Unchecked = 0
SetGadgetItemState(#Gadget, item, #PB_ListIcon_Unchecked)
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:
Code: Select all
If GetGadgetItemState(...) & #PB_ListIcon_Unchecked
; do something
EndIf
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.
Re: Please add #PB_ListIcon_Unchecked constant
Posted: Tue Sep 29, 2009 8:39 am
by Kaeru Gaman
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...
Re: Please add #PB_ListIcon_Unchecked constant
Posted: Tue Sep 29, 2009 6:01 pm
by USCode
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)
Ah, I gotcha now.
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.
I agree. Maybe an short extra blurb in the doc or example on how to uncheck might help alleviate any confusion.
Thanks again