I''m using an RXTable in my application and I would like to be able to select a row and then press the Delete key to delete the selected row. This does not seem to work, however, as apparently keypresses are not initially recognized. In my FXTable derived class I have: connect(SEL_KEYRELEASE) do |sender, selector, event| puts "code = #{''%X'' % event.code}" case event.code when KEY_Delete, KEY_KP_Delete puts "Delete key hit" # process... # ... end end When I left-click on a row header, the row gets properly selected and highlighted, but hitting any key does not result in being recognized (i.e., the messages above do not appear). If I then click on a table cell, then subsequent keypresses cause the connected code to fire, and things work as expected. Do I have to do something to receive key events initially? -- Will
Shouldn''t it be FXTable.connect(Fox::SEL_KEYRELEASE) do |sender, selector, event| I use foxGUIb so if i am wrong i stand corrected to others who know better. rgds, Dave ________________________________ From: Will Parsons <wbparsons at cshore.com> To: fxruby-users at rubyforge.org Sent: Sat, 10 April, 2010 8:59:14 AM Subject: [fxruby-users] Problem detecting keypresses in FXTable I''m using an RXTable in my application and I would like to be able to select a row and then press the Delete key to delete the selected row. This does not seem to work, however, as apparently keypresses are not initially recognized. In my FXTable derived class I have: connect(SEL_KEYRELEASE) do |sender, selector, event| puts "code = #{''%X'' % event.code}" case event.code when KEY_Delete, KEY_KP_Delete puts "Delete key hit" # process... # ... end end When I left-click on a row header, the row gets properly selected and highlighted, but hitting any key does not result in being recognized (i.e., the messages above do not appear). If I then click on a table cell, then subsequent keypresses cause the connected code to fire, and things work as expected. Do I have to do something to receive key events initially? -- Will _______________________________________________ fxruby-users mailing list fxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/fxruby-users -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20100409/6d560c59/attachment.html>
William B. Parsons
2010-Apr-11 23:29 UTC
[fxruby-users] Problem detecting keypresses in FXTable
On Fri, 9 Apr 2010 18:25:00 -0700 (PDT) dave L <dglnz at yahoo.com> wrote:> Shouldn''t it be FXTable.connect(Fox::SEL_KEYRELEASE) do |sender, selector, event| > > I use foxGUIb so if i am wrong i stand corrected to others who know better.No, I think the syntax is correct - after all, it does work as expected after a mouse click on a table cell. Here''s a small test program to illustrate the problem: --------------------------------------------------------------------------------------- #!/usr/bin/env ruby require ''fox16'' include Fox class TopLevelWindow < FXMainWindow def initialize(app) super(app, ''Test'', :width => 420, :height => 150) frame = FXVerticalFrame.new(self, :opts => FRAME_SUNKEN|LAYOUT_FILL) table = FXTable.new(frame, :opts => LAYOUT_FILL) table.setTableSize(5, 3) table.connect(SEL_SELECTED) do |sender, selector, data| if data.col == 0 puts "row #{data.row} selected" end end table.connect(SEL_KEYPRESS) do |sender, selector, event| puts "code = #{''%X'' % event.code}" end end def create super show(PLACEMENT_SCREEN) end end app = FXApp.new(ARGV[0]) TopLevelWindow.new(app) # kick off application app.create app.run --------------------------------------------------------------------------------------- After selecting a row initially, keypresses (or releases) are not dectected until there is a mouse click within a cell, after which key presses/releases are detected. What I want to do - select a row and then press to Del/Delete key to delete it - I would think would a fairly common thing to want to do when dealing with tables. Haven''t other people come across this issue? ___________________________> From: Will Parsons <wbparsons at cshore.com> > To: fxruby-users at rubyforge.org > Sent: Sat, 10 April, 2010 8:59:14 AM > Subject: [fxruby-users] Problem detecting keypresses in FXTable > > I''m using an RXTable in my application and I would like to be able to > select a row and then press the Delete key to delete the selected row. > This does not seem to work, however, as apparently keypresses are not > initially recognized. In my FXTable derived class I have: > > connect(SEL_KEYRELEASE) do |sender, selector, event| > puts "code = #{''%X'' % event.code}" > case event.code > when KEY_Delete, KEY_KP_Delete > puts "Delete key hit" > # process... > # ... > end > end > > When I left-click on a row header, the row gets properly selected and > highlighted, but hitting any key does not result in being recognized > (i.e., the messages above do not appear). If I then click on a table > cell, then subsequent keypresses cause the connected code to fire, and > things work as expected. Do I have to do something to receive key > events initially?-- William B. Parsons <wbparsons at cshore.com>