[fxruby-users] No accelTable for an FXTabItem?
Philippe Lang
philippe.lang at attiksystem.ch
Fri Feb 16 08:50:59 EST 2007
Jeroen van der Zijp wrote:
>> Apparently, accelTable is not initialized in the FXTabItem class.
>>
>> FXTabItem is derived from FXWindow and should have an accelTable
>> attribute, right?
>
> It has a variable for accel table, but no accel table has been added
> yet. However, after you add an accel table, you should certainly be
> able to add accelerator key-combinations to it then!
Hi,
I've tried initializing the accel table, the error has disappeared, but
the tab item does not react to CTRL-S at all. Something to enable maybe?
One more question: what happens if three tabs have the same hotkey
configured in their respective accel table? Do they all receive the
callback, or only the active tab? I'd like to code something similar to
the second solution, but I'm not sure how to do that...
Regards,
Philippe Lang
===========================================
require 'fox16'
include Fox
class MyTabItem < FXTabItem
include Responder
ID_SAVE = FXTabItem::ID_LAST
def initialize(p, text, ic=nil, opts=TAB_TOP_NORMAL, x=0, y=0,
width=0, height=0, padLeft=DEFAULT_PAD, padRight=DEFAULT_PAD,
padTop=DEFAULT_PAD, padBottom=DEFAULT_PAD)
super(p, text, ic, opts, x, y, width, height, padLeft, padRight,
padTop, padBottom)
FXHorizontalFrame.new(p,
FRAME_RAISED|LAYOUT_FILL_X|LAYOUT_FILL_Y)
FXMAPFUNC(SEL_COMMAND, MyTabItem::ID_SAVE, 'onSave')
accelTable = FXAccelTable.new()
accelTable.addAccel(fxparseAccel("Ctrl-S"), self,
FXSEL(SEL_COMMAND, MyTabItem::ID_SAVE))
end
def onSave(sender, selector, data)
puts "save in MyTabItem"
end
end
class MyWindow < FXMainWindow
#include Responder
#ID_SAVE = FXMainWindow::ID_LAST
def initialize(app)
super(app, "Window", nil, nil, DECOR_ALL, 0, 0, 200, 100)
tabbook = FXTabBook.new(self, nil, 0,
LAYOUT_FILL_X|LAYOUT_FILL_Y)
tabitem1 = MyTabItem.new(tabbook, "tab 1")
tabitem2 = MyTabItem.new(tabbook, "tab 2")
tabitem3 = MyTabItem.new(tabbook, "tab 3")
#FXMAPFUNC(SEL_COMMAND, MyWindow::ID_SAVE, 'onSave')
#accelTable.addAccel(fxparseAccel("Ctrl-S"), self,
FXSEL(SEL_COMMAND, MyWindow::ID_SAVE))
end
def onSave(sender, selector, data)
puts "save in MyWindow"
end
def create
super
show(PLACEMENT_SCREEN)
end
end
if __FILE__ == $0
application = FXApp.new("Fox", "FXRuby Test")
MyWindow.new(application)
application.create
application.run
End
===========================================
More information about the fxruby-users
mailing list