[fxruby-users] FXTable copy/paste issue

2 views
Skip to first unread message

William Parsons

unread,
Jul 1, 2012, 5:01:02 PM7/1/12
to foxgui...@lists.sourceforge.net, fxruby...@rubyforge.org
I have an issue with using C-c/C-v for copy/paste in FXTable in an application
which uses fxruby under X. (I suspect this is a FOX rather than fxruby issue.)
If I use C-c to copy the contents of a cell that contains a comma (',') and then
try to paste it using C-v into another cell, the contents get pasted into two
adjacent cells with the contents split at the comma, e.g.,

| Hartford, Ct | -> | Hartford | Ct |

and if fact, if the target cell is in the last column of the table, a *new*
column springs up unbidden to hold the second part. Is there a way of avoiding
this?

--
William Parsons
_______________________________________________
fxruby-users mailing list
fxruby...@rubyforge.org
http://rubyforge.org/mailman/listinfo/fxruby-users

Lars Kanis

unread,
Jul 4, 2012, 12:11:12 PM7/4/12
to fxruby...@rubyforge.org, foxgui...@lists.sourceforge.net
2012/7/1 William Parsons <wbpa...@alum.mit.edu>:
> I suspect this is a FOX rather than fxruby issue.

Yes, you're right, it is a libfox issue. There is a hard coded split
in fox/src/FXTable.cpp#1528 that is used for pasting from the
clipboard. Columns are separated by "\t" or "," and rows by "\n". I
verified this for libfox-1.6.45 and for 1.7.33.

In order to work around this limitation you may do the insertion from
clipboard by yourself. You could do this by deriving FXTable. This
works for Linux. For other OS you may have to try alternatives to
FXTable.utf8Type as seen in src/FXTable.cpp.

class MyFXTable < Fox::FXTable
include Responder
def initialize(*args, &block)
super
FXMAPFUNC(SEL_COMMAND, FXTable::ID_PASTE_SEL, 'onCmdPasteSel')
end
def onCmdPasteSel(sender, sel, ptr)
data = getDNDData(FROM_CLIPBOARD, FXTable.utf8Type)
if data && anythingSelected?
rows_cols = data.split("\n").map{|l| l.split("\t") }
row_nr = selStartRow
max_cols = 0
rows_cols.each do |cols|
col_nr = selStartColumn
cols.each do |text|
setItemText( row_nr, col_nr, text)
col_nr += 1
end
row_nr += 1
max_cols = [max_cols, cols.length].max
end
selectRange(selStartRow, selStartRow+rows_cols.length-1,
selStartColumn, selStartColumn+max_cols-1)
end
end
end


You may file a bug on the fox toolkit?

--
Regards,
Lars
Reply all
Reply to author
Forward
0 new messages