[fxruby-users] Accelerators on Tab and FXText

Marshall T. Vandegrift llasram at gmail.com
Mon Feb 1 09:28:33 EST 2010


Hi,

I've found what seems to be a bug, although I'm not sure whether in
Fox, FXRuby, or my use thereof.  The issue is that when an FXText
widget has focus, keyboard accelerators bound on the "Tab" key are
"hijacked" by the FXText widget.  At least on my system, Shift+Tab is
actually Shift+ISO_Left_Tab, so in effect this means just Ctrl+Tab is
so affected.  The code which follows should demonstrate the issue: the
accelerators on Ctrl+N and Ctrl+Shift+Tab work and print messages on
the console when either the text box or button has focus, but the
accelerator on Ctrl+Tab only invokes it's handler when the button has
focus.

I'm running fxruby 1.6.20 and libfox 1.6.36-1 (Debian testing).

Any suggestions appreciated.  Thanks!

-Marshall

Code follows:

require 'fox16'

include Fox

class AcceleratorBug < FXMainWindow
  include Responder

  ID_CTRL_N = ID_LAST + 1
  ID_CTRL_TAB = ID_CTRL_N + 1
  ID_CTRL_SHIFT_TAB = ID_CTRL_TAB + 1

  def initialize(app)
    super(app, "Accelerator Bug")
    frame = FXVerticalFrame.new(self, LAYOUT_FILL)
    FXText.new(frame, :opts => LAYOUT_FILL | LAYOUT_SIDE_TOP)
    FXButton.new(frame, "whatever", :opts => LAYOUT_FILL_X)
    FXMAPFUNC(SEL_COMMAND, ID_CTRL_N, :on_ctrl_n)
    accelTable.addAccel(fxparseAccel("Ctrl+N"),
                        self, FXSEL(SEL_COMMAND, ID_CTRL_N))
    FXMAPFUNC(SEL_COMMAND, ID_CTRL_TAB, :on_ctrl_tab)
    accelTable.addAccel(fxparseAccel("Ctrl+Tab"),
                        self, FXSEL(SEL_COMMAND, ID_CTRL_TAB))
    accelTable.addAccel(fxparseAccel("Alt+Tab"),
                        self, FXSEL(SEL_COMMAND, ID_CTRL_TAB))
    FXMAPFUNC(SEL_COMMAND, ID_CTRL_SHIFT_TAB, :on_ctrl_shift_tab)
    accelTable.addAccel(fxparseAccel("Ctrl+Shift+Tab"),
                        self, FXSEL(SEL_COMMAND, ID_CTRL_SHIFT_TAB))
    accelTable.addAccel(Fox.MKUINT(KEY_ISO_Left_Tab, CONTROLMASK | SHIFTMASK),
                        self, FXSEL(SEL_COMMAND, ID_CTRL_SHIFT_TAB))
  end

  def on_ctrl_n(sender, sel, data)
    puts "You pushed Ctrl+N!"
  end

  def on_ctrl_tab(sender, sel, data)
    puts "You pushed Ctrl+Tab!"
  end

  def on_ctrl_shift_tab(sender, sel, data)
    puts "You pushed Ctrl+Shift+Tab!"
  end

  def self.main(argv=ARGV)
    app = FXApp.new
    window = AcceleratorBug.new(app)
    app.create
    window.show
    app.run
    return 0
  end
end

if __FILE__ == $0
  exit(AcceleratorBug::main)
end


More information about the fxruby-users mailing list