[Solved] Multiple unwanted rows add to ListIconGadget

Just starting out? Need help? Post your questions and find answers here.
radsoft
User
User
Posts: 25
Joined: Mon Sep 11, 2017 2:03 am
Location: New Zealand

[Solved] Multiple unwanted rows add to ListIconGadget

Post by radsoft »

Hi everybody,

I'm at the very early stage of learning PureBasic. I'm expecting that ultimately my main interest will be in using the database functions and with this in mind I experimented with the ListIconGadget. I was expecting a single row to be added to the ListIconGadget when I click the button in my little program below but when I run the program, a button click causes three rows to be added and then two rows for each click thereafter. I must be doing something very silly.

I'm running PureBasic 6.00 LTS (Windows - x64) on Windows 10 Pro 64 bit.

Can someone tell me what I'm doing wrong please.

Thanks in advance

Code: Select all

myWindow = OpenWindow(#PB_Any, 10, 10, 640, 480, "Test")

btnAddLine = ButtonGadget(#PB_Any, 20, 20, 100, 50, "Add Item")
myListIconGadget = ListIconGadget(#PB_Any, 20, 90, 600, 370, "My Data", 600)
btnExit = ButtonGadget(#PB_Any, 520, 20, 100, 50, "Exit")

Repeat
  event = WaitWindowEvent()
  
  If #PB_Event_Gadget
    gadget = EventGadget()
    
    If gadget = btnAddLine
      AddGadgetItem(myListIconGadget, -1, "Hello")
    EndIf
    
    If gadget = btnExit
      event = #PB_Event_CloseWindow
    EndIf
    
  EndIf
  
Until event = #PB_Event_CloseWindow
Last edited by radsoft on Tue Aug 16, 2022 5:13 am, edited 1 time in total.
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Multiple unwanted rows add to ListIconGadget

Post by TI-994A »

In the event loop:

Code: Select all

If event = #PB_Event_Gadget
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
radsoft
User
User
Posts: 25
Joined: Mon Sep 11, 2017 2:03 am
Location: New Zealand

Re: Multiple unwanted rows add to ListIconGadget

Post by radsoft »

Thank you so much TI-994A, we're sorted.

Regards
Post Reply