Lazarus

Programming => Widgetset => Cocoa => Topic started by: han on May 17, 2020, 04:23:50 pm

Title: Listview1.SelectAll doesn't work in Cocoa
Post by: han on May 17, 2020, 04:23:50 pm

The method
Code: [Select]
Listview1.SelectAll
doesn't work in Cocoa. It works in Windows and Linux.

I also tried:

Code: [Select]
procedure select_all(tt :tlistview);
var
  i:integer;
begin
  tt.Items.BeginUpdate;
  for i := 0 to tt.Items.Count-1 do tt.Items[i].Selected:=true;
  tt.Items.EndUpdate;
  tt.setfocus;{set focus for next ctrl-C. Somehow it is lost}
end;

Anybody an idea how to get this working?

Han
Title: Re: Listview1.SelectAll doesn't work in Cocoa
Post by: trev on May 18, 2020, 10:21:15 am
Confirmed.

Code: Pascal  [Select][+][-]
  1. procedure TfrmMain.ListView1SelectItem(Sender: TObject; Item: TListItem;
  2.   Selected: Boolean);
  3. begin
  4.      Inc(count);
  5.      if(count <= 10) then
  6.        ListView1.Items[count].Selected:=true;
  7.      WriteLn('Count: ' + IntToStr(ListView1.SelCount));
  8. end;    
  9.  

SelectAll does not select any, but it does fire the SelectItem event the right number of times :)

Putting the ListView1.Items[count].Selected:=true; in the event handler only selects Item 11 (the last allowed in this test with 100 items).

Best log a bug report.
Title: Re: Listview1.SelectAll doesn't work in Cocoa
Post by: han on May 18, 2020, 10:35:21 am
Thanks for confirming. I will raise a bug report:

https://bugs.freepascal.org/view.php?id=37103
Title: Re: Listview1.SelectAll doesn't work in Cocoa
Post by: skalogryz on May 18, 2020, 01:48:44 pm
is MultiSelect property of ListView set to true?
Title: Re: Listview1.SelectAll doesn't work in Cocoa
Post by: trev on May 18, 2020, 03:04:27 pm
Yes, in my test it was set true. Once in the OI and once in code, to be sure, to be sure.
Title: Re: Listview1.SelectAll doesn't work in Cocoa
Post by: skalogryz on May 18, 2020, 04:10:34 pm
Yes, in my test it was set true. Once in the OI and once in code, to be sure, to be sure.
how does it work on r63183?
Title: Re: Listview1.SelectAll doesn't work in Cocoa
Post by: trev on May 19, 2020, 12:11:52 am
Fails to compile :(

Code: [Select]
Compiling cocoawscomctrls.pas
Compiling cocoatabcontrols.pas
cocoatabcontrols.pas(161,3) Note: Local variable "r" not used
cocoatabcontrols.pas(242,3) Note: Local variable "x" not used
cocoatabcontrols.pas(242,5) Note: Local variable "y" not used
cocoatabcontrols.pas(251,3) Note: Local variable "v" not used
cocoatabcontrols.pas(437,3) Note: Local variable "idx" not used
cocoatabcontrols.pas(480,3) Note: Local variable "r" not used
Assembling (pipe) ../../units/x86_64-darwin/cocoa/cocoatabcontrols.s
<stdin>:51526:10: warning: section "__datacoal_nt" is deprecated
.section __DATA, __datacoal_nt, coalesced
         ^      ~~~~~~~~~~~~~~
<stdin>:51526:10: note: change section name to "__data"
.section __DATA, __datacoal_nt, coalesced
         ^      ~~~~~~~~~~~~~~
<stdin>:51575:10: warning: section "__datacoal_nt" is deprecated
.section __DATA, __datacoal_nt, coalesced
         ^      ~~~~~~~~~~~~~~
<stdin>:51575:10: note: change section name to "__data"
.section __DATA, __datacoal_nt, coalesced
         ^      ~~~~~~~~~~~~~~
cocoawscomctrls.pas(639,3) Note: Local variable "lTitle" not used
cocoawscomctrls.pas(818,13) Warning: Range check error while evaluating constants (9223372036854775807 must be between -2147483648 and 2147483647)
cocoawscomctrls.pas(896,3) Note: Local variable "lOldTabStyle" is assigned but never used
cocoawscomctrls.pas(909,3) Note: Local variable "lOldTabStyle" is assigned but never used
cocoawscomctrls.pas(1305,3) Warning: Case statement does not handle all possible cases
cocoawscomctrls.pas(1559,3) Fatal: Syntax error, ";" expected but "ELSE" found
Fatal: Compilation aborted
make[3]: *** [../lcl.ppu] Error 1
make[2]: *** [cocoa_all] Error 2
make[1]: *** [interfaces] Error 2
make: *** [lcl] Error 2
trev@macmini6 [/Users/trev/lazarus-src] $
Title: Re: Listview1.SelectAll doesn't work in Cocoa
Post by: skalogryz on May 19, 2020, 02:30:36 am
hmm. odd. r63184
Title: Re: Listview1.SelectAll doesn't work in Cocoa
Post by: trev on May 19, 2020, 02:42:09 am
Compiles and now SelectALL selects all - see pic :)
TinyPortal © 2005-2018