

Fudley
Members-
Content Count
81 -
Joined
-
Last visited
Everything posted by Fudley
-
Claude a. I. Recently I've had three opportunities to use Claude in my D12 Fmx development. 1. Needed to know how to scroll to a TListboxitem that was not visible. I had three different solutions off the net - none of which worked. Claude provided me with three different solutions, suggesting that #2 would be best for android. It worked a treat! I've been wrestling this one for a while... 2. I have about 50 color themes for this app. I needed help naming them. My wife just rolled her eyes. I uploaded a text list in the form: Theme Name 1: #Hexcolor1 #Hexcolor2 #Hexcolor3 #Hexcolor4 Theme Name 2: #Hexcolor1 #Hexcolor2 #Hexcolor3 #Hexcolor4 Claude provide a list of names almost instantly - and they were 90% spot on. (i.e. Wedgewood became Limestone Quarry) 3. I have a certain unique store/shopping type to represent, and was trying to layout a table structure for the store. I described the store and what it selling and what I needed to Claude. I got back a very long and detailed description, including the field structure and types. Anyway it saved me a lot of time.
-
FMX-Android-D12 Scroll TListbox selected item into view What I've tried (where lb is a TListbox and newindex is the new itemindex): 1. newindex := lb.selected.index; lb.scrollby(0.0,lb.itemheight*newindex) 2. oldindex := lb.ItemIndex; rowheight := lb.Selected.Height; lb.ViewportPosition := PointF(0,rowheight*oldindex) ; 3. lb.ScrollToItem(lb.Selected); Neither of these work. Please advise. Much thanks.
-
Here's what Claude (the a.i.) suggested when I asked this question (and #2 does work best on android): ------------------------------ // Solution 1: Using ScrollToItem with proper timing procedure ScrollSelectedItemIntoView_Method1(lb: TListBox); begin if (lb.Selected <> nil) then begin // Use TThread.Queue to ensure the UI is updated before scrolling TThread.Queue(nil, procedure begin lb.ScrollToItem(lb.Selected); end); end; end; // Solution 2: Manual viewport positioning (most reliable) procedure ScrollSelectedItemIntoView_Method2(lb: TListBox); var ItemTop, ItemBottom, ViewportTop, ViewportBottom: Single; NewViewportY: Single; begin if (lb.Selected <> nil) and (lb.Count > 0) then begin // Get the selected item's position ItemTop := lb.Selected.Position.Y; ItemBottom := ItemTop + lb.Selected.Height; // Get current viewport bounds ViewportTop := lb.ViewportPosition.Y; ViewportBottom := ViewportTop + lb.Height; // Calculate new viewport position if needed NewViewportY := ViewportTop; // If item is above viewport, scroll up if ItemTop < ViewportTop then NewViewportY := ItemTop // If item is below viewport, scroll down else if ItemBottom > ViewportBottom then NewViewportY := ItemBottom - lb.Height; // Apply the new viewport position if NewViewportY <> ViewportTop then lb.ViewportPosition := PointF(0, NewViewportY); end; end; // Solution 3: Using item index with proper calculations procedure ScrollSelectedItemIntoView_Method3(lb: TListBox); var ItemIndex: Integer; ItemY: Single; ViewportHeight: Single; begin if (lb.Selected <> nil) then begin ItemIndex := lb.Selected.Index; ViewportHeight := lb.Height; // Calculate the Y position of the item ItemY := ItemIndex * lb.ItemHeight; // Check if item is outside viewport if (ItemY < lb.ViewportPosition.Y) or (ItemY + lb.ItemHeight > lb.ViewportPosition.Y + ViewportHeight) then begin // Center the item in the viewport lb.ViewportPosition := PointF(0, ItemY - (ViewportHeight / 2) + (lb.ItemHeight / 2)); end; end; end; // Solution 4: Enhanced method with smooth scrolling option procedure ScrollSelectedItemIntoView_Method4(lb: TListBox; SmoothScroll: Boolean = False); var ItemRect: TRectF; ViewportRect: TRectF; TargetY: Single; begin if (lb.Selected <> nil) then begin // Get item bounds ItemRect := lb.Selected.BoundsRect; // Get viewport bounds ViewportRect := RectF(0, lb.ViewportPosition.Y, lb.Width, lb.ViewportPosition.Y + lb.Height); // Check if item is fully visible if not ViewportRect.Contains(ItemRect) then begin // Calculate target scroll position if ItemRect.Top < ViewportRect.Top then TargetY := ItemRect.Top else if ItemRect.Bottom > ViewportRect.Bottom then TargetY := ItemRect.Bottom - lb.Height else TargetY := lb.ViewportPosition.Y; // Ensure we don't scroll beyond content bounds TargetY := Max(0, Min(TargetY, lb.ContentBounds.Height - lb.Height)); if SmoothScroll then begin // Smooth scroll using animation lb.AniCalculations.Animation := True; lb.AniCalculations.TouchTracking := []; lb.ViewportPosition := PointF(0, TargetY); end else begin // Immediate scroll lb.ViewportPosition := PointF(0, TargetY); end; end; end; end; // Usage examples: procedure TForm1.Button1Click(Sender: TObject); begin // Select an item programmatically if ListBox1.Count > 5 then begin ListBox1.ItemIndex := 5; // Then scroll it into view using any of the methods above ScrollSelectedItemIntoView_Method2(ListBox1); end; end; // Alternative: Create a helper method in your form procedure TForm1.SelectAndScrollToItem(lb: TListBox; ItemIndex: Integer); begin if (ItemIndex >= 0) and (ItemIndex < lb.Count) then begin lb.ItemIndex := ItemIndex; // Use a small delay to ensure selection is processed TThread.CreateAnonymousThread(procedure begin TThread.Synchronize(nil, procedure begin ScrollSelectedItemIntoView_Method2(lb); end); end).Start; end; end; // For Android-specific optimizations, you might want to disable animations // during scrolling to improve performance: procedure OptimizeForAndroid(lb: TListBox); begin lb.AniCalculations.Animation := False; lb.AniCalculations.TouchTracking := []; end; Key Points: Method 2 is the most reliable - it manually calculates viewport positioning and works consistently across different Android devices. Timing is crucial - Sometimes you need to use TThread.Queue or TThread.Synchronize to ensure the UI has updated before scrolling. Your original attempts failed because: ScrollBy doesn't work well with viewport positioning Direct ViewportPosition assignment needs proper bounds checking ScrollToItem can be unreliable without proper timing Android-specific considerations: Disable animations during programmatic scrolling for better performance Consider the device's screen density and scaling factors Test on different Android versions and screen sizes Recommended approach: Use Method 2 for most cases, or Method 4 if you want smooth scrolling. For Android deployment, consider disabling animations during programmatic scrolling to improve performance. The key difference from your attempts is proper bounds checking and ensuring the viewport position is calculated relative to the actual item positions rather than just multiplying by item height.RetryClaude can make mistakes. Please double-check responses.
-
Odd question (ok, so no change then ) It seems in order to update any files I'm deploying to the assets\internal\ folder I have to do the following: -on the android device, app storage, I do "clear cache", "clear data" and then "uninstall" -in D12, delete the files in question from deployment -in D12, add them back to deployment, setting the remote path to assets\internal\ ....build, run and Bobs your uncle Do I really need all these steps? Can this be streamlined at all?
-
I tried "-doallmywork"but no effect.
-
Todd thanks so much that works like a charm! And just a general big thanks to everyone here who is so very helpful to an old dbase-foxpro-clipper-delphi-windows programmer!
-
A number of controls are not themed, like TRectangle, TLine and the svg.overridecolor on TkSvg. I would like to set these to match the current theme. How can I find the currently used theme color of a control I know is themed, so I can then apply it to the non-themed controls at runtime? For instance TLabel themed fontcolor would do nicely to use for svg.overridecolor on TkSvg,. TLabel themed fontcolor would work (for me) for TRectangle.stroke TButtons themed fill color could be used for TRectangle.fill For me, this would save oodles of work. thanks all
-
How to find the currently used theme color of a themed control
Fudley replied to Fudley's topic in FMX
I found this does not effect embedded TFrames, so I wrote a frame-specific TMyMainForm.ColorMyFramesWorld(aFrame:TFrame_) that does essentailly the same thing with the children of the frame. TMyMainForm.ColorMyWorld; -
How to find the currently used theme color of a themed control
Fudley replied to Fudley's topic in FMX
With serge_g's help: procedure TMyMainForm.ColorMyWorld; var ThisComp : TComponent; iComponentCount, iThis : integer; TextObj : TText; begin // gotstylelabel is a TLabel TextObj := TText(gotstylelabel.FindStyleResource('text')); if Assigned(TextObj) then begin iComponentCount := ComponentCount; {form componentcount} try for iThis := 0 to iComponentCount-1 do begin ThisComp := Components[iThis]; if ThisComp is TRectangle then TRectangle(ThisComp).Stroke.color := TextObj.Color else if ThisComp is TLine then TLine(ThisComp).Stroke.color := TextObj.Color else if ThisComp is TskSVG then TskSVG(ThisComp).svg.overrideColor := TextObj.Color ; end; except end; end; end -
delphi 12, fmx, android What is a simple technique for sending communications from one TForm to another TForm? (other than filling a hidden label or clicking a hidden button on the target form maybe?)
-
How to find the currently used theme color of a themed control
Fudley replied to Fudley's topic in FMX
Serge_G Thanks so much! that worked perfectly!!!! -
Wow thanks so much that worked perfectly!
-
That looks promising Rollo62. Say I want FormB to send an integer message to FormA i.e. 999 and have FormB receive and perform the instruction represented by 999. i.e. case integer-message of 1: 2: 3: 99: perform task 99 end How would I set up it up. I am still confused by the TMessageManager subscribe and unsubsribe, and how to send message from one to the other.
-
This just started happening, and I can't figure out what changed. All existing controls on the form respond to OnTap events as usual. If I add a new control to the form, such as a button or label, its OnTap event does not fire. For instance, if I drop a button (Button9) on the form, and assign its OnTap event as follows, nothing happens when I tap it. procedure TFudleyMain.Button9Tap(Sender: TObject; const Point: TPointF); begin showmessage('HERE'); end; Anyone ever experience this?
-
Well FM, it happened again today. Anyone have any clues please? Reinstall Delphi?
-
What I am doing to load a .style file from disk: if FileExists(SelectedStyleFile) then begin Application.mainform.stylebook.LoadFromFile(SelectedStyleFile) ; end; How do I then apply the style?
-
D12, Android 14 I have added a file to the deployment tab. Local name is abc.xyz Remote path is set as assets\internal , remote name is abc.xyz How do I load this file at runtime? I can't find it with FileExists function. I've tried variations of the TPath.Get* path functions i.e. FileExists( tpath.combine(TPath.GetAppPath,'abc.xyz) ); Basically , how do I locate the file deployed to assets\internal at runtime
-
Thanks Remy that's a great resource. Link saved for reference.
-
I had to revert back to an earlier version and manually redo the changes one by one since then. I still don't know how or why it happened.
-
Well I tried on Android 12 and 14 - same problem. Scratching head...
-
Sorry - Delphi 12, Windows 11. However my test phone did upgrade to Android 15 today...
-
Yes! Thank you very much Dave. I am constantly amazed at your knowledge.
-
I need to get a cheap tablet for testing. -Needs to work with Windows 11. and Delphi 12. -Preferably under $150. Any recommendations?
-
To follow up, I was able to get a 7 inch and 10 inch for testing. Glad I did! Have to adjust a few things
-
Hi François , I am so sorry I really messed up that description! - We are developing apps for Android, using Delphi 12, on Windows 11. - We need an Android tablet to be used only for testing the android apps. (and possibly as a Kindle alternative 📓) - We want to spend under $150 if possible (OK if it is used or reconditioned) -I am used to Samsung, so that would be a plus I hope that is more lucid. Thanks!