TWebCheckListBox.OnClickCheck not returning the clicked item on ItemIndex

Hello,

I am trying to determine which item on a TWebCheckListBox was toggled and I always receive a -1 value regardless of user selection. I am expecting to receive the Index that the user clicked on instead so I can examine the clicked item and do what I need to do.

Here is how the TWebCheckListBox is setup

var
cblPermissions: TWebCheckListBox;

cblPermissions := TWebCheckListBox.Create(Self);

cblPermissions.Name := 'cblPermissions';
cblPermissions.Parent := WebPanel3;
cblPermissions.Left := 366;
cblPermissions.Top := 235;
cblPermissions.Width := 329;
cblPermissions.Height := 273;
cblPermissions.HeightPercent := 100.00000000000000000;
cblPermissions.ItemHeight := 15;
cblPermissions.TabOrder := 6;
cblPermissions.WidthPercent := 100.00000000000000000;
cblPermissions.OnClickCheck := cblPermissionsClickCheck;

And here is the event handler for OnClickCheck:

procedure TfEditUser.cblPermissionsClickCheck(Sender: TObject);
var
  Index: Integer;
begin
  if Sender is TWebCheckListBox then
  begin
    Index := TWebCheckListBox(Sender).ItemIndex;
      {$IFDEF DEBUG}console.log('cblPermissionsClickCheck: clicked index is ' + Index.ToString);{$ENDIF}
    If Index <> -1 then
      TRoleStatus(TWebCheckListBox(Sender).Items.Objects[Index]).NewCheckedStatus := TWebCheckListBox(Sender).Checked[Index];
  end;
end;

I am not sure how I should do this on TMS Web Core as this same code works on VCL.
If this is not the proper way to do this in Web Core, can you please point me in the right direction?

Thanks,

Alan

Thanks for reporting.
We could trace & solve this issue to make it work similar to VCL.
Next update will address this.

Thanks!
Can you give me an idea of when this will be released. It is a showstopper on my side.
Alan

We hope a matter of days, still finishing some TWebDataGrid enhancements,...

Thank you for the info

Here is a quick fix I did in the WebLib.CheckLst source file to get the index of the item clicked. This should get you going until there is a more permanent fix available.

function TCheckListBox.HandleDoClickCheck(Event: TJSMouseEvent): Boolean;
var
  idx: integer;
  el: TJSElement;
begin
  el := ElementHandle;
  asm
   idx = Array.from(el.firstChild.firstChild.children).indexOf(Event.target.parentElement);
  end;
  if (idx >= 0) then
  begin
    IntChecked(idx, Checked[idx]);
  end;

  if Assigned(OnClickCheck) then
  begin
    Self.Tag := idx;  <--- Assigned the index of the item to the tag
    OnClickCheck(Self); <--- Reference tag in the click event
  end;
  Result := true;
end;