[fxruby-users] selective disabling of text entry in a FXTable

William B. Parsons wbparsons at cshore.com
Wed Jan 7 17:22:53 EST 2009


Hello,

I'm working on my first application using FXRuby, and am trying to disable
text entry in certain columns of a FXTable, but calling disableItem() on
a cell doesn't seem to prevent editing a cell.  Do I misunderstand the use
of disableItem()?

The following test program illustrates what I'm trying to do:

----------------------------
#!/usr/bin/env ruby
require 'fox16'
include Fox

class TestTable < FXTable
   def initialize(p, title)
      super(p, :opts => LAYOUT_FILL|HSCROLLING_OFF)
      setTableSize(0, 3)

      column_label = [ "A", "B", "C" ]
      column_label.each_index { |i| setColumnText(i, column_label[i]) }

      connect(SEL_KEYRELEASE) do |sender, selector, event|
         puts "cell #{currentRow}, #{currentColumn} "+
            "#{itemEnabled?(currentRow, currentColumn)?'en':'dis'}abled"
      end
   end

   def add_row(label)
      n = getNumRows
      insertRows(n)
      setRowText(n, label)
      disableItem(n, 2)
   end
end

class TopLevelWindow < FXMainWindow
   def initialize(app)
      super(app, 'Test', :width => 400, :height => 90)

      w = TestTable.new(self, "Test")
      w.add_row("X")
      w.add_row("Y")
      w.add_row("Z")
   end

   def create
      super
      show(PLACEMENT_SCREEN)
   end
end

FXApp.new('Test', 'Wikareia') do |app|
   TopLevelWindow.new(app)
   app.create
   app.run
end
-- 
William B. Parsons <wbparsons at cshore.com>


More information about the fxruby-users mailing list