[fxruby-users] problems with FXMessageBox apparenlty generating SEL_SELECTED in a FXTable

5 views
Skip to first unread message

William Parsons

unread,
Aug 1, 2012, 6:25:17 PM8/1/12
to fxruby...@rubyforge.org
Hi,

I have an aplication that uses an FXTable and does some processing on a selected row in response to a SEL_CHANGED message. The processing can throw an exception, so I want to catch it and put up a FXMessageBox if this happens.

The problem I am seeing is that if the FXMessageBox is shown, additional selections are generated causing the message box to get re-instanciated after it has been dismissed when the cursor is moved. I am including a stripped down test version of the real application below that illustrates the problem.

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

require 'rubygems'
require 'fox16'

include Fox

class App < FXApp
def initialize
super('Test', 'Test')
TopLevelWindow.new(self)
end
end

class TestTable < FXTable
def initialize(p)
super(p, :opts => LAYOUT_FILL|TABLE_COL_SIZABLE)

setTableSize(20, 1)
self.rowHeaderMode = 0
setColumnWidth(0, 200)

connect(SEL_SELECTED) do |sender, selector, data|
puts "SEL_SELECTED #{selStartRow}-#{selEndRow} [#{data.row},#{data.col}]"
end

connect(SEL_CHANGED) do |sender, selector, data|
selected_row = selStartRow
puts "SEL_CHANGED begin #{selStartRow}"
if selected_row > -1
killSelection
begin
if selected_row%2 == 1
raise "exception processing row #{selected_row}"
end
puts "row #{selected_row} successfully processed"
rescue
FXMessageBox.error(self, MBOX_OK, 'Error', $!.to_s)
end
puts "SEL_CHANGED end #{selStartRow}"
end
end
end
end

class TopLevelWindow < FXMainWindow
def initialize(app)
super(app, 'Test', :width => 200, :height => 500)
frame = FXPacker.new(self, :opts => FRAME_SUNKEN|LAYOUT_FILL)
TestTable.new(frame)
end

def create
super
show(PLACEMENT_SCREEN)
end
end

app = App.new
app.create
app.run

-------------------------------------------------------------------------------

--
Will
_______________________________________________
fxruby-users mailing list
fxruby...@rubyforge.org
http://rubyforge.org/mailman/listinfo/fxruby-users
Reply all
Reply to author
Forward
0 new messages