TValueListEditor editing behavior lazarus / 31-LCL ---------------------------------------------------------------------- RubioTerra · 2020-10-29 20:22 I have a TValueListEditor in a form and I'm trying to enter a key on the first column. But whenever I enter an equals sign (=) two equals sign add immediately prepended to the values column. I didn't find any option that would justify this behavior. Is this a bug? I'm using Lazarus v2.0.10.r63526 on Windows 10. ---------------------------------------------------------------------- Bart · 2020-10-29 21:31 That's quite interesting behaviour. D7 raises an error if you enter an equal sign in the key column. Please file a bugreport, so it won't be forgotten. I'll try to fix it when I have the time. Bart ---------------------------------------------------------------------- RubioTerra · 2020-10-29 21:40 Thanks, @Bart. So the correct behavior would be raising an error? This would mean I'm using the component the wrong way. I'm trying to use it to enter pairs of find/replace regexes. I was under the impression that it would support any pair of strings. ---------------------------------------------------------------------- Bart · 2020-10-29 22:40 If you enter the key/values in the grid, you are not supposed to type a '=', just type the key in the left column, the value in the right. If you want to enter key/value pairs by code, better use the Strings property: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   ValueListEditor1.Strings.Add('foo=bar');Make sure to hide the editor before you do that. Bart ---------------------------------------------------------------------- Bart · 2020-10-29 22:43 Quote from: RubioTerra on October 29, 2020, 10:40:59 pmSo the correct behavior would be raising an error? D7 does, but I'm inclined not to implement it in that way. I can suppress typing an equal sign in the Key column (it is allowed and supported in the Value column). The tricky part is suppressing pasting an equal sign into the Key column. Also I cannot figure out why pressing '=' behaves like you described: it should never change the Value column. Bart ---------------------------------------------------------------------- egsuh · 2020-10-30 02:58 It is because default namevalueseparator is equal sign (=) in TStrings (or TStringlist?). If you run following code, Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     StrLst := TStringList.Create;     StrList.Values['aname'] := 'AValue';     Showmessage(StrList.Text); This will show            aname=AValue Internally Name-value pairs are stored as name=value. I do not understand why two equal signs are added to the value column, but you can change the NameValueSeparator character to other one which will not be used. So run following sentence before you  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i    ValueListEditor1.Strings.NameValueSeparator := '\'; And then equal signs will be entered to the key colume in ValueListEditor. ---------------------------------------------------------------------- Bart · 2020-10-30 09:07 I committed a fix in r64089 and r64090. New behaviour: If you type '=' (actually: the current NameValueSeparator) in the Keys column, you will be moved to the Value column (as if you had pressed VK_Right). If you paste an equal sign into the Keys column, this will be removed from the Key value. I decided NOT to raise an exception for that, because that would require an global exception handler to handle this at the user level. Please test. Bart ---------------------------------------------------------------------- egsuh · 2020-10-31 01:41 QuoteI committed a fix in r64089 and r64090. How can I update the fixes?  --> This is not my main question. With Lazarus 2.0.10, I still see that when the ValueListEditor is focused and copy strings to the ValueListEditor, i.e.          ValueListEditor1.Strings.Text := AStringList.Text; The the first row value is left blank. Is this fixed? ---------------------------------------------------------------------- dsiders · 2020-10-31 02:19 Quote from: egsuh on October 31, 2020, 02:41:30 amQuoteI committed a fix in r64089 and r64090. How can I update the fixes?  --> This is not my main question. With Lazarus 2.0.10, I still see that when the ValueListEditor is focused and copy strings to the ValueListEditor, i.e.          ValueListEditor1.Strings.Text := AStringList.Text; The the first row value is left blank. Is this fixed? what bug report? ---------------------------------------------------------------------- jamie · 2020-10-31 14:41 Quote from: egsuh on October 31, 2020, 02:41:30 amQuoteI committed a fix in r64089 and r64090. How can I update the fixes?  --> This is not my main question. With Lazarus 2.0.10, I still see that when the ValueListEditor is focused and copy strings to the ValueListEditor, i.e.          ValueListEditor1.Strings.Text := AStringList.Text; The the first row value is left blank. Is this fixed? how about just implementing the KeyDown event and detect for a  "=" as you are typing ? when found, reject the key and move the focus over to the VALUE column . ---------------------------------------------------------------------- wp · 2020-10-31 15:05 And why don't you just press ENTER? This will move the focus into the second column as well. Introducing unconventional keys is really not a good idea. ---------------------------------------------------------------------- jamie · 2020-10-31 15:06 Here is an example for you that works for me  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.ValueListEditor1KeyDown(Sender: TObject; var Key: Word;  Shift: TShiftState);beginif (key = vk_oem_plus)and(not (ssshift in shift)) then with TvalueListEditor(Sender) do begin    col := 1;  // move to the right column of not already there.    key := 0; //eat the key end;end;                             you could also add some nice back steps here to get back into the key column of you wish by processing the backspace key... ---------------------------------------------------------------------- egsuh · 2020-10-31 15:41 Sorry if my explanations were not sufficient.  Putting equal sign in Key colume is solved, as Bart said. It is related with default NameValueSeparator and programmer should solve it. My question is not related with the previous issue. When I try to copy the content of other TStrings to TValueListEditor, it is not done  correctly (the first Value is left blank) if the TValueListEditor is focused. I've written this issue at another thread in this forum before, and now I'm asking whether it is solved. ---------------------------------------------------------------------- jamie · 2020-10-31 16:18 Quote from: egsuh on October 31, 2020, 04:41:13 pmSorry if my explanations were not sufficient.  Putting equal sign in Key colume is solved, as Bart said. It is related with default NameValueSeparator and programmer should solve it. My question is not related with the previous issue. When I try to copy the content of other TStrings to TValueListEditor, it is not done  correctly (the first Value is left blank) if the TValueListEditor is focused. I've written this issue at another thread in this forum before, and now I'm asking whether it is solved. I don't know what to tell you ? I see you demonstrated using a Tstringlist but I am not sure that really is the issue at hand with a valuelist..  are you having issues with Strniglist or the valueeditor ? ---------------------------------------------------------------------- bytebites · 2020-10-31 17:36 Does setting valuelist column to zero solve the problem? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var  AStringList: TStringList;begin  ValueListEditor1.Col:=0;  AStringList:=TStringList.create;  AStringList.AddPair('hello','world',nil);  AStringList.AddPair('moon','shadow',nil);  ValueListEditor1.Strings.Text := AStringList.Text;end; procedure TForm1.ValueListEditor1KeyPress(Sender: TObject; var Key: char);begin  if key='a' then begin Button1Click(nil);key:=#0;end;end; ---------------------------------------------------------------------- Bart · 2020-10-31 18:04 Quote from: egsuh on October 31, 2020, 02:41:30 amQuoteI committed a fix in r64089 and r64090.How can I update the fixes?  --> This is not my main question. I did not request this to be merged to the fixes branch. The new behaviour ('=' -> goto Value column) breaks existing behaviour. It's more of a new feature than a fix (it's part of the way I implemented the fix though). The second part of the fix: reverting a pasted '=' is a bit more tricky. I don't know it this (how I did it) is the correct way, so I do not want that merged to fixes. Let it be in trunk for a while. There is an easy workaround: assign OnKeyPress to the ValueListEditor, suppress '='  if Col equals zero. Alternatively: Implement EditorCanAcceptChar for TValueListEditor and do it (suppressing '=') there. Quote from: egsuh on October 31, 2020, 02:41:30 amWith Lazarus 2.0.10, I still see that when the ValueListEditor is focused and copy strings to the ValueListEditor, i.e.          ValueListEditor1.Strings.Text := AStringList.Text; The the first row value is left blank. Is this fixed? With trunk (and this should also work in current stable) I do Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     ValEd.Strings.Assign(memo1.lines);  //ValEd.Strings.Text := Memo1.Text; {behaves exactly the same} Where the content of Memo1 is: Code: [Select]Key0=Value0 Key1=Value1 Key2=Value2 This works as expected. And IIRC this has worked for a long time. Bart ---------------------------------------------------------------------- egsuh · 2020-11-01 05:02 QuoteLet it be in trunk for a while. I do not know what trunk means exactly, but I'll be waiting for later versions which incorporate those changes. Thank you. ---------------------------------------------------------------------- Bart · 2020-11-01 11:13 Quote from: egsuh on November 01, 2020, 06:02:26 amI do not know what trunk means exactly Trunk is the development branch. Releases are split of from trunk and form a different branch then, so development can go on and only fixes will be merged to the release branch (called fixes branch in our case). See the Lazarus Devolpment Process article on the wiki. Bart