Thank you very much for reply on my question! You're the maintainer of the 
module "uing", isn't it? Thanx for your work!

Back to topic: i've looked at your new example with csv file. And i read yout 
first answer feeled a hundred times... but i'am ashamed - i don't get it to 
work :(

you mentioned, to alter the "list" sequence, to take effect on the table... I 
think i've done it in the proc of the button.

I' done some corrections but it does not alter the table: i see the values 
"dummy 1" and "dummy 2" as the init values of my "list", but when i click the 
button, the new values were added to the "list" value, but the new values do 
not append to the tabel :( what i'm doing wrong? Am i such stupid ;(
    
    
    from uing/rawui import nil
    import uing
    
    var list: seq[string] = @["dummy1", "dummy2"]
    
    proc modelNumColumns(mh: ptr TableModelHandler, m: ptr rawui.TableModel): 
cint {.cdecl.} = 0
    proc modelNumRows(mh: ptr TableModelHandler, m: ptr rawui.TableModel): cint 
{.cdecl.} =
      result = cint(list.len())
    
    proc modelColumnType(mh: ptr TableModelHandler, m: ptr rawui.TableModel, 
col: cint): TableValueType {.cdecl.} =
      result = TableValueTypeString
    
    proc modelCellValue(mh: ptr TableModelHandler, m: ptr rawui.TableModel, 
row, col: cint): ptr rawui.TableValue {.cdecl.} =
      return newTableValue(list[row]).impl
    
    proc modelSetCellValue(mh: ptr TableModelHandler, m: ptr rawui.TableModel, 
row, col: cint, val: ptr rawui.TableValue) {.cdecl.} =
      rawui.tableModelRowChanged(m, row)
    
    proc main() =
      var mainwin: Window
      
      let menu = newMenu("File")
      menu.addQuitItem(
        proc(): bool =
          mainwin.destroy()
          return true
      )
      
      mainwin = newWindow("Table", 640, 480, true)
      mainwin.margined = true
      
      let box = newVerticalBox(true)
      mainwin.child = box
      
      var mh: TableModelHandler
      mh.numColumns = modelNumColumns
      mh.columnType = modelColumnType
      mh.numRows = modelNumRows
      mh.cellValue = modelCellValue
      mh.setCellValue = modelSetCellValue
      
      var p: TableParams
      p.model = newTableModel(addr mh).impl
      p.rowBackgroundColorModelColumn = -1
      
      let table = newTable(addr p)
      table.addTextColumn("My Header", 0, TableModelColumnNeverEditable)
      
      let btn = newButton("click me...", proc(sender: Button)=
        list.add(@["one", "two", "three", "four"])
        echo list.len()
      )
      box.add btn, false
      box.add table, true
      
      show mainwin
      mainLoop()
    
    init()
    main()
    
    
    Run

Perhaps you have time and want push me to the right way? 

Reply via email to