Sha256: edab9a75564b6bf97ca15b3fbeb4cff7b4b968e2db142a051799a20bcfb84ab1

Contents?: true

Size: 1.89 KB

Versions: 30

Compression:

Stored size: 1.89 KB

Contents

module Fox
  
  class FXApp

    alias addInputOrig addInput # :nodoc:

    #
    # Add a file descriptor _fileDesc_ to be watched for activity as determined
    # by _mode_, where _mode_ is a bitwise OR (+INPUT_READ+, +INPUT_WRITE+, +INPUT_EXCEPT+).
    # A message of type +SEL_IO_READ+, +SEL_IO_WRITE+, or +SEL_IO_EXCEPT+ will be sent 
    # to the target when the specified activity is detected on the file descriptor.
    #
    # There are several forms for #addInput; the original form (from FOX)
    # takes four arguments:
    #
    #   anApp.addInput(fileDesc, mode, anObject, aMessageId)
    #
    # A second form takes three arguments:
    #
    #   anApp.addInput(fileDesc, mode, aMethod)
    #
    # For this form, _aMethod_ should have the standard argument list
    # for a FOX message handler. That is, the method should take three
    # arguments, for the message _sender_ (an FXObject), the message _selector_,
    # and the message _data_ (if any).
    #
    # The last form of #addInput takes a block:
    #
    #   anApp.addInput(fileDesc, mode) { |sender, sel, data|
    #     ... handle the I/O event ...
    #   }
    #

    def addInput(fd, mode, *args, &block)
      params = {}
      params = args.pop if args.last.is_a? Hash
      tgt, sel = nil, 0
      if args.length > 0
        if args[0].respond_to? :call
          tgt = FXPseudoTarget.new
          tgt.pconnect(SEL_IO_READ, args[0], params)
          tgt.pconnect(SEL_IO_WRITE, args[0], params)
          tgt.pconnect(SEL_IO_EXCEPT, args[0], params)
        else # it's some other kind of object
          tgt = args[0]
          sel = args[1]
        end
      else
        tgt = FXPseudoTarget.new
        tgt.pconnect(SEL_IO_READ, block, params)
        tgt.pconnect(SEL_IO_WRITE, block, params)
        tgt.pconnect(SEL_IO_EXCEPT, block, params)
      end
      addInputOrig(fd, mode, tgt, sel)
    end
    
  end # class FXApp
  
end # module Fox

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
fxruby-1.6.22.pre2-x86-mingw32 lib/fox16/input.rb
fxruby-1.6.22.pre2 lib/fox16/input.rb
fxrubi-1.6.22.pre1-x86-mingw32 lib/fox16/input.rb
fxrubi-1.6.22.pre1 lib/fox16/input.rb
fxruby-1.6.20-x86-mingw32 lib/fox16/input.rb
fxruby-1.6.20-x86-linux lib/fox16/input.rb
fxruby-1.6.20 lib/fox16/input.rb
fxruby-1.6.20-universal-darwin-10 lib/fox16/input.rb
fxruby-1.6.19-x86-mingw32 lib/fox16/input.rb
fxruby-1.6.14-mswin32 lib/fox16/input.rb
fxruby-1.6.13-mswin32 lib/fox16/input.rb
fxruby-1.6.12 lib/fox16/input.rb
fxruby-1.6.13 lib/fox16/input.rb
fxruby-1.6.14-universal-darwin-9 lib/fox16/input.rb
fxruby-1.6.14 lib/fox16/input.rb
fxruby-1.6.15-universal-darwin-9 lib/fox16/input.rb
fxruby-1.6.15-x86-mswin32-60 lib/fox16/input.rb
fxruby-1.6.15 lib/fox16/input.rb
fxruby-1.6.16-universal-darwin-9 lib/fox16/input.rb
fxruby-1.6.16-x86-mswin32-60 lib/fox16/input.rb