Code Monkey home page Code Monkey logo

Comments (2)

kojix2 avatar kojix2 commented on June 2, 2024

Hi @AndyObtiva

As you said, it looks like you need to write SetCellValue.
I think the following example will work.

model_handler.SetCellValue = rbcallback(0, [1, 1, 4, 4, 1]) do |_, _, row, column, val|
  data[row][column] = UI.table_value_string(val).to_s
end

Thank you for creating glimmer-dsl-libui!


rbcallback(0, [1, 1, 4, 4, 1])

require 'fiddle'
Fiddle.constants.each do |c|
  if c.to_s.start_with? "TYPE_"
    puts "#{c}\t#{Fiddle.const_get(c)}"
  end
end
TYPE_VOID       0
TYPE_CHAR       2
TYPE_SHORT      3
TYPE_LONG_LONG  6
TYPE_INT8_T     2
TYPE_INT16_T    3
TYPE_INT32_T    4
TYPE_INT64_T    6
TYPE_FLOAT      7
TYPE_DOUBLE     8
TYPE_VARIADIC   9
TYPE_CONST_STRING       10
TYPE_SIZE_T     -6
TYPE_SSIZE_T    6
TYPE_PTRDIFF_T  6
TYPE_INTPTR_T   6
TYPE_UINTPTR_T  -6
TYPE_LONG       5
TYPE_INT        4
TYPE_VOIDP      1

from libui.

AndyObtiva avatar AndyObtiva commented on June 2, 2024

Thank you. The code worked. I'll look into amending it for the different column types in the future.

I just released Glimmer DSL for LibUI 0.0.19 with examples/editable_table.rb:

require 'glimmer-dsl-libui'

include Glimmer

data = [
  %w[cat meow],
  %w[dog woof],
  %w[chicken cock-a-doodle-doo],
  %w[hourse neigh],
  %w[cow moo]
]

window('Editable animal sounds', 300, 200) {
  horizontal_box {
    table {
      text_column('Animal')
      text_column('Description')

      cell_rows data
      editable true
    }
  }
  
  on_closing do
    puts 'Bye Bye'
  end
}.show

I will be providing another version that enables setting the editable property on specific column(s) only instead of the entire table

Cheers.

from libui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.