[fxruby-users] Data Targets and message handlers [was: Default double-click in FXTable?]

Philippe Lang philippe.lang at attiksystem.ch
Sat Oct 7 08:15:15 EDT 2006


Hi,

I have read that message handlers can return a value, either true or false, depending on if the handler actually did something, or not. In the latter case, the message is forwarded to the default message handler.

I have tried this, and found something strange: in this code, decommenting:

    @data_widget.connect(SEL_KEYPRESS) do |sender, selector, data|
        puts d.code
        false
    end

... breaks the update of the textfield. The handler returns false in every case, it should have no effect at all, no?

I'm I missing something maybe?

Philippe


----------------------------
#!/usr/bin/ruby

require 'fox16'

include Fox

class MyWindow < FXMainWindow
    
  def initialize(app)

    super(app, "Window", nil, nil, DECOR_ALL, 0, 0, 200, 100)

    # Menu bar stretched along the top of the main window
    menubar = FXMenuBar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
  
    # File menu
    filemenu = FXMenuPane.new(self)
    FXMenuTitle.new(menubar, "&File", nil, filemenu)
    FXMenuCommand.new(filemenu, "&Quit\tCtl-Q\tQuit the application",
        nil, app, FXApp::ID_QUIT)

    # Frames
    frame = FXMatrix.new(self, 4,
        LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_THICK|FRAME_RAISED)

    # Data target
    @data_target = FXDataTarget.new()
    
    # Widget
    @data_widget = FXTextField.new(frame, 5, @data_target, FXDataTarget::ID_VALUE)
    
    # We put some data into the data target
    @data_target.value = 123
    
    # We add a message handler
    #@data_widget.connect(SEL_KEYPRESS) do |sender, selector, data|
    #    puts d.code
    #    false
    #end
    
  end

  def create
    super
    show(PLACEMENT_SCREEN)
  end

end

if __FILE__ == $0
  application = FXApp.new("Attik System", "FXRuby Test")
  MyWindow.new(application)
  application.create
  application.run
end


---------------
Philippe Lang
Attik System

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3125 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/fxruby-users/attachments/20061007/1b2af216/attachment-0001.bin 


More information about the fxruby-users mailing list