Search code examples
firemonkeydelphi-11-alexandriatrackbar

FMX TrackBar Control issue/bug?


Ok - I'm new to Delphi and FMX (been 30+ years since I've programmed in Pascal). I've downloaded Delphi 11 Community Edition and have written approx 1800 lines of functional code since Friday night. In my GUI - I added a FMX Trackbar. I've noticed that the Up/Down arrow keys appear to operate it in the reverse manner, i.e. UP arrow key decrements the value stored, the DOWN arrow key increments the value stored. This appears counter intuitive (for reference, LEFT arrow decrements and RIGHT arrow increments). Is this a bug or intention? Any workarounds? If a bug, anyone have any ideas on how to get this resolved? I've attempted to rotate and the reverse the max and minimum values (as a work around - but this didn't work either, min can not be greater than max - which is logical but...)

I'm expecting that UP arrow would/should INCREMENT TrackBar.value and DOWN arrow would DECREMENT TrackBar.value, whether in vertical or horizontal orientations.


Solution

  • That looks like a bug to me, but there's an easy workaround (which you'd have to remove if/when the bug gets fixed!).

    Create an event handler for the TTrackBar's OnKeyDown event, and put the following code in that event handler:

    procedure TViewForm.TrackBar1KeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
    begin
      if key=vkUp   then key:=vkDown    else
      if key=vkDown then key:=vkUp;
    end;
    

    Go to https://quality.embarcadero.com/ to report this bug.