0

I'm looking for a way to get a certain Delphi Firemonkey TTrackbar behavior change in my Delphi 10.1 Seattle Android app.

What do I want to achieve? The trackbar has a thumb the user can move. It runs on a track and the side of the track left from the thumb until the left end of the track will be colored by default to indicate the value chosen with the thumb.

I want it reversed: the track right from the thumb until the right end of it shall have this color.

I was pointed into the direction of styles already but after learning a little bit about those I still don't fully understand how to do it for my case and I start to doubt that just changing the style will work.

I dropped a TTrackbar on a form, right clicked on it and choose "edit custom style". I found that there is a htrack which consists of the background, a TRectangle and the highlight, which is a TStyleObject. Being a TStyleObject it is linked to a region in a png file via SourceLookup and SourceLink. But there my wisdom stops.

  1. how to find that png?
  2. even if I find it, what to do next? I don't want to change the appearance of that "highlight" TStyleObject, I want to change its position. I already tried to have it right anchored, but that's of course only part of the solution, as the width calculation at runtime would need to be "inverted" (1-x) as well.
0

1 Answer 1

3

Instead of modifying the style, consider rotating the trackbar. Set property RotationAngle to 180 and property Value to same as Max (if you want to have the thumb initially to the left). Then, when using the Value calculate it e.g. as:

procedure TForm21.TrackBar1Change(Sender: TObject);
begin
  Label1.Text := IntToStr(trunc((Sender as TTrackBar).Max -
                                (Sender as TTrackBar).Value));
end;

Visually it looks like this:

Trackbar orientation change


Edit after comment

It turns out that rotation with 180° doesn't work on real Android devices (at least not on some models) as reported by OP to the Embarcadero quality portal ( RSP-13156 )

2
  • I'm sorry to say this: but your answer as good as it looks (I had the idea with the 180 degrees myself already) shows that you didn't test it on a real Android device yet. At least in D10 Seattle Trackbars rotated by angles > 85 degrees (might be 84 or 86 actually, start to behave strange and a 180 degree rotated TTrackbar is only being displayed in the form designer. On the device it's invisible, even if it still reacts on interaction with it. I dutyfully reported it into Quality Portal,: link But thanks for trying to help me!
    – Markus
    Jan 26, 2016 at 17:45
  • 1
    @Markus Arrgh. It's true that I did not test on a real device (I don't have any Android). One would expect Emba to have sorted out such elementary errors through all these years with FMX. Of course I voted for your RSP. I make a note in my answer. Jan 26, 2016 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.