[fxruby-users] some extesions to FXRuby classed

Joel VanderWerf vjoel at path.berkeley.edu
Tue Apr 10 17:20:37 EDT 2007


Lyle,

These are some standard extensions that I usually throw in when I am 
using FXRuby. (They are in FoxTails actually.)

What do you think about adopting them into FXRuby?


module Fox
   class FXTextField
     # Add #editable as alias for #editable?.
     # Two reasons for this:
     #
     # (1) consistency with #enabled and #enabled? being aliases.
     #
     # (2) having a traditional r/w pair (#foo and #foo=) is helpful
     #     with metaprogramming.
     alias :editable :editable? unless 
instance_methods(true).include?("editable")
   end

   class FXTable
     # For parallelism with selectRange.
     unless instance_methods(true).include?("deselectRange")
       def deselectRange(sr, er, sc, ec, notify = false)
         changes = false
         for row in sr..er
           for col in sc..ec
             changes |= deselectItem(row, col, notify)
           end
         end
         return changes
       end
     end
   end

   class FXWindow
     # Traverse all children, depth first (parent before child).
     def each_child_recursive
       each_child do |child|
         yield child
         child.each_child_recursive do |subchild|
           yield subchild
         end
       end
     end
   end
end


-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407


More information about the fxruby-users mailing list