I was looking at ways to make it easy to copy between 2 listboxes.
I found here what it looks like a good way to do it. The problem is that I get the following:
I have a listbox that sometimes the cell content is multiline (2 lines at most). I have code on CellBackgroundPaint (handle the alternate color) and CellTextPaint (to draw the text correctly when it is 2 lines).
The code used to copy the rows (I put that on listbox1 DoubleClick) is the one listed on the other thread:
Why the original code doesn’t work? I thought that lb2.cell(x,-1)=lb1.cell(y,-1) internally is like lb2.cell(x,0)=lb1.cell(y,0) and lb2.cell(x,1)=lb1.cell(y,1). I guess it doesn’t like the EndOfLine that is on the first cell.
I believe when you use (-1), what really happens is the TEXT in the row or column is transfered and reparsed… it does not reiterate thru the cells and move it one by one, which is what you did in your second example
so the first way… it ended up with “11112222” which then got truncated during the move
[quote]EndOfLine on macOS
NOTE: Starting with 2013r1, EndOfLine returns EndOfLine.Unix on all macOS apps.
This change was necessary because 2013r1 creates Cocoa apps by default and Cocoa works with the Unix line endings.
If you require the old behavior, you should explicitly use EndOfLine.Macintosh.[/quote]
So why the clipboard changed the EndOfLine.Unix to EndOfLine.Macintosh?
Maybe the clipboard and the cell (-1) code need to be updated?
And now using EndOfLine.Windows and the clipboard:
Dim s As String = "1" + EndOfLine.Windows + "2"
TextArea1.Text = s
Dim c As New Clipboard
c.Text = s
Dim s2 As String = c.Text
c.Close
s2 on Mac: 310D 0D32
s2 on Windows: 310D 0A32
s2 on Linux: 310D 0A32
and changing the code (1 line) to:
c.Text = TextArea1.Text
s2 on Mac: 310D 0D32
s2 on Windows: 310D 32
s2 on Linux: 310D 0A32
Edit: remote tested on Linux Mint and added above
Edit2: I hope someone will understand my information
Thank you Emile. Sorry, I think I jumped from one thing to another then another. I’ll try to post all the problems here, I think they are related (a little).
1.- this code doesn’t work if I use chr(10) as EndOfLine on listboxes with multiline cell, but works if chr(13) is usedl:
2.- when something is copied to the clipboard on a mac if the EOL is chr(10) then it is changed to chr(13). EndOfLine.Windows is chr(13)+chr(10) but when copied to the clipboard (on a mac) it is changed to chr(13)+chr(13)
3.- using EndOfLine.Windows on Windows you usually get chr(13)+chr(10) but when you do a TextArea.Text = String then chr(10) is lost, so you only get chr(13)
What I expected:
if I use chr(10), a) the lb.cell(x,-1) should work and b) do not change to chr(13) when copied to the clipboard
if using EndOfLine.Windows, always have chr(13)+chr(10) (just like my latest test with Linux)
Yes, I have used ReplaceLineEndings, but how you never used EndOfLine. when the example show:
Dim s As String
s = ReplaceLineEndings(TextField1.Text, EndOfLine.Windows)
Do you only put EndOfLine there and let Xojo add the EndOfLine for each platform? (Unix for Mac and Linux and Windows for Windows)
I did a test with this code:
Dim s As String = "1" + EndOfLine + "2"
TextArea1.Text = s
Dim c As New Clipboard
c.Text = TextArea1.Text
Dim s2 As String = c.Text
c.Text = ReplaceLineEndings(c.Text,EndOfLine)
Dim s3 As String = c.Text
c.Close
On Mac (using the hex values to see the differences):
s = 310A 32
s2 = 310D 32
s3 = 310D 32
in this case, ReplaceLineEndings can’t change 0D back to 0A for clipboard
On Windows:
s = 310D 0A32
s2 = 310D 32
s3 = 310D 0A32
in this case, ReplaceLineEndings fixed what the clipboard had (could be a clipboard bug?)
On Linux:
s = 310A 32
s2 = 310A 32
s3 = 310A 32
in this case, there is no need to use ReplaceLineEndings because the clipboard didn’t change the LineEnding. This is what I expect on Mac and Windows.
Because I get an advice that do not display the one you refer to. And that example worked fine, so I never try anything else.
For Listbox with many lines in a Row (a Cell with many Lines): I know only one ine is displayed by default and do accordingly. If I have to display many lines in a Cell, I made a copy of the text in a TextField (with many lines set ON).
Have a look at Feedback Release Notes: select one Row and read how it is displayed when there is more than one line in a Cell (there are examples).
I visited the Feedback Release Notes, almost all cells that don’t fit the space are single line. I found for 2017r3 case id 49039 as one with an EndOfLine, but I can’t know if it is using chr(10), chr(13) or both (I think it will look the same no matter which).
I understand this “issue” is minor because it works as expected (at least it looks like that) visually. In other words, if I have a multiline TextField or TextArea with chr(10) copy that to clipboard (changed to chr(13)) and then I paste that again on another TextArea it will look the same. I may file a bug report.
CHANGE 47859 Framework » All Add new Drag events to the Listbox, changes include:
I removed all other lines (they are a ton or more !).
Only the firt line is displayed (or part of the first line), the remainder is displayed in the TextArea, below the Listbox.
In a project, I have three (or four ?) columns that may have 3 or more lines They are accessible in vew by Card (All fields in a window), and when I print them (as PDF) Short: no trouble at all.
That application runs in both Windows (7) and macOS (many different versions).
Yes, the RowHeight is for each/every Row. You can see that on the image I posted (first column). I changed the Height to be able to display 2 lines.
My code detects if there are 2 lines or only 1. If there are 2, then the first line is drawn half the text distance above what normally will draw, and the second line half the text height below. That way it looks right. If there is only 1 line, then it is draw as default on the middle of the cell.