Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • Lazarus Lazarus
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 2,099
    • Issues 2,099
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 14
    • Merge requests 14
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • FPC
  • LazarusLazarus
  • LazarusLazarus
  • Issues
  • #33386
Closed
Open
Issue created Mar 08, 2018 by FPC Admin account@fpc_adminOwner

Selecting disabled item in TRadioGroup

Original Reporter info from Mantis: giovanni.seara
  • Reporter name: Giovanni Seara

Description:

When RadioGroup has any items disabled, when browsing through VK_DOWN, the disabled item is selected and an exception is generated.

Steps to reproduce:

1 - Add one TRadioGroup in the Form.
2 - Add four items in the TRadioGroup.
3 - Disable the second and third items of TRadioGroup.
4 - Execute the Form.
5 - Whith the Form executing, click in the first item of the TRadioGroup.
6 - Press VK_DOWN (At this point, the button of Item2 is checked and the focus is on item 4. An exception has been raised).
7 - Press VK_DOWN again (At this point, the Item3 button is checked and the focus is on Item1. An exception has also been raised).

Additional information:

The possible fix for the error is to change the ItemKeyDown procedure of the TCustomRadioGroup:

procedure TCustomRadioGroup.ItemKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
  procedure MoveSelection(HorzDiff, VertDiff: integer);
  var
    Count: integer;
    StepSize: integer;
    BlockSize : integer;
    NewIndex : integer;
    WrapOffset: integer;
  begin
    Count := FButtonList.Count;
    if FColumnLayout=clHorizontalThenVertical then begin
      //add a row for ease wrapping
      BlockSize := Columns * (Rows+1);
      StepSize := HorzDiff + VertDiff * Columns;
      WrapOffSet := VertDiff;
    end
    else begin
      //add a column for ease wrapping
      BlockSize := (Columns+1) * Rows;
      StepSize := HorzDiff * Rows + VertDiff;
      WrapOffSet := HorzDiff;
    end;
    NewIndex := ItemIndex + StepSize;

    { Code correct }
    while ((NewIndex>=Count) or (NewIndex<0)) or
      not TRadioButton(FButtonList[NewIndex]).Enabled do
      NewIndex := (NewIndex + StepSize) mod BlockSize;
 
    { Code wrong
    if (NewIndex>=Count) or (NewIndex<0) then begin
      NewIndex := (NewIndex + WrapOffSet + BlockSize) mod BlockSize;
      // Keep moving in the same direction until in valid range
      while NewIndex>=Count do
        NewIndex := (NewIndex + StepSize) mod BlockSize;
    end; }

    ItemIndex := NewIndex;
    TRadioButton(FButtonList[ItemIndex]).SetFocus;
    Key := 0;
  end;
  
begin
  if Shift=[] then begin
    case Key of
      VK_LEFT: MoveSelection(-1,0);
      VK_RIGHT: MoveSelection(1,0);
      VK_UP: MoveSelection(0,-1);
      VK_DOWN: MoveSelection(0,1);
    end;
  end;
  if Key <> 0 then
    KeyDown(Key, Shift);
end;       

Mantis conversion info:

  • Mantis ID: 33386
  • OS: Windows
  • OS Build: 10
  • Platform: Desktop
  • Version: 1.9 (SVN)
  • Fixed in revision: 57483 (#f0012094)
  • Monitored by: » giovanni.seara (Giovanni Seara)
  • Target version: 1.8.4
Assignee
Assign to
Time tracking