Wrong value for CountGadgetItems at Treegadget

Just starting out? Need help? Post your questions and find answers here.
IB-Software
User
User
Posts: 15
Joined: Sat Jun 21, 2003 12:11 pm

Wrong value for CountGadgetItems at Treegadget

Post by IB-Software »

Example

Code: Select all

If OpenWindow(0, 216, 0, 290, 530, "",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)  
  TreeGadget(1, 30, 30, 230, 380)
  AddGadgetItem(1,-1,"2010",0,0)
  AddGadgetItem(1,-1,"2011",0,0)
  AddGadgetItem(1,-1,"2012",0,2)
  AddGadgetItem(1,-1,"2013",0,0)
  AddGadgetItem(1,-1,"2014",0,2)
  AddGadgetItem(1,-1,"2015",0,2)
  AddGadgetItem(1,-1,"2016",0,2)  
  Debug CountGadgetItems (1)
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow 
EndIf
End
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Wrong value for CountGadgetItems at Treegadget

Post by Shardik »

I can't confirm your finding! I have tested your example on these operating systems and all report 7, which is the correct count of entries in the TreeGadget:
- MacOS 10.6.8 'Snow Leopard' with PB 5.46 x86 and PB 5.62 in ASCII and Unicode mode
- MacOS 10.14.6 'Mojave' with PB 5.70 x64
- Linux Mint 19.2 'Tina' x64 with Cinnamon and PB 5.71 x64
- Windows 10 x64 V1809 with PB 5.70 x86

By the way, your code contains an error: in AddGadgetItem() you specify a node level of 2 before having specified a node level of 1. On MacOS (not on Linux and Windows!) you therefore obtain the following output (being unable to expand the nodes):
2010
2011
2013

After replacing value 2 with 1 in AddGadgetItem() and opening the parent nodes the correct output is displayed:
2010
2011
- 2012
2013
- 2014
- 2015
- 2016

Nevertheless in both cases the output of CountGadgetItems() is correct: 7
IB-Software
User
User
Posts: 15
Joined: Sat Jun 21, 2003 12:11 pm

Re: Wrong value for CountGadgetItems at Treegadget

Post by IB-Software »

The error in MacOS is that the value of CountGadgetItems does not match the number of items in the TreeGadget.

I have deliberately specified level 2 as this will cause the error. If you specify a wrong level, PureBasic should either report an error, correct the error (as in Windows) on its own or not create the entries.

But in any case the value of CountGadgetItems must correspond to the number of entries in the TreeGadget.
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Wrong value for CountGadgetItems at Treegadget

Post by Shardik »

Which version of MacOS are you using and which version of PureBasic? And which value does CountGadgetItems() display with your example from your first posting?

As I have written for Snow Leopard and Mojave, although the output with node level 2 is incorrect, the result returned from CountGadgetItems() is 7 and therefore correct.
IB-Software wrote:If you specify a wrong level, PureBasic should either report an error, correct the error (as in Windows) on its own or not create the entries.
I agree.
IB-Software
User
User
Posts: 15
Joined: Sat Jun 21, 2003 12:11 pm

Re: Wrong value for CountGadgetItems at Treegadget

Post by IB-Software »

I tested with MacOS Mojave and PureBasis 5.70. 3 entries are displayed:

2010
2011
2013

But CountGadgetItems returns 7. This is wrong because only three items are displayed.
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Wrong value for CountGadgetItems at Treegadget

Post by Josh »

IB-Software wrote:But CountGadgetItems returns 7. This is wrong because only three items are displayed.
What is so hard to understand about the function name CountGadgetItems()? This function does exactly what the name says, it returns how many items the Gadget has.

Again a typical example. Don't know anything, but post in the bugs immediately. Please can a mod move this drama to the garbage?
sorry for my bad english
IB-Software
User
User
Posts: 15
Joined: Sat Jun 21, 2003 12:11 pm

Re: Wrong value for CountGadgetItems at Treegadget

Post by IB-Software »

Ok, even if the CountGadgetItems function returns the correct value, based on the AddGadgetItem function, although the TreeGadget displays a different number of entries, then the different handling of the "wrong" levels in MacOS and Windows is a bug in any case.
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: Wrong value for CountGadgetItems at Treegadget

Post by Bisonte »

IB-Software wrote:Ok, even if the CountGadgetItems function returns the correct value, based on the AddGadgetItem function, although the TreeGadget displays a different number of entries, then the different handling of the "wrong" levels in MacOS and Windows is a bug in any case.
This is not a bug, if you "forget" one stage. You go from 0 to 2... there is a little 1 between them....
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
Post Reply