NizamUlMulk Posted October 3, 2019 Posted October 3, 2019 When key press over the list box (multiselect and ordered), the item is selected, but the scroll doesn´t move to that item. Ex. Press G words from the keyboard and listbox stays same as before, but, if manually scroll the list until found an item beginning with G, that item seems selected! How move the scroll programatically until the selected item? Quote
NizamUlMulk Posted October 3, 2019 Author Posted October 3, 2019 I found! if somebody has same problem. The solution is: with UniListBox1 do JSInterface.JSCall('boundList.getSelectedNodes()['+inttostr(SelCount-1)+'].scrollIntoView', [True]); Solved Quote
NizamUlMulk Posted October 7, 2019 Author Posted October 7, 2019 procedure TMainForm.myListKeyPress(Sender: TObject; var Key: Char); var vector: TArray<string>; index: Integer; begin with TUniListBox(Sender) do begin if Items.Count = 0 then Exit; Key := UpCase(Key); vector := Items.ToStringArray; TArray.BinarySearch<string>(vector, Key, index, TStringComparer.Ordinal); if index > -1 then begin ItemIndex := index; JSInterface.JSCall('boundList.getSelectedNodes()['+inttostr(SelCount-1)+'].scrollIntoView', [True]); Selected[index] := False; end; end; end; 1 Quote
jackamin Posted September 9, 2020 Posted September 9, 2020 Hello, First of all, thank you for sharing your solution! Unfortunately, it did not work for me in Delphi XE10, in a UniGui application that runs in synchronous mode. I got the following error message: HOWEVER! I was able to fix the problem by calling UniSession.Synchronize() between the Delphi code and the JavaScript code. The following worked for me: UniListBox1.ItemIndex:=11; UniSession.Synchronize(); UniListBox1.JSInterface.JSCall('boundList.getSelectedNodes()[0].scrollIntoView', [True]); Note that I hard-coded '0' as the selected node index. This is because UniListBox1 does not have multi-select enabled. Also note that, in the MainModule, the EnableSynchronousOperations property must be set to 'True' to use UniSession.Synchronize(), but you should read this guide before deciding to run your application in synchronous mode. Hope it helps someone! -Jack Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.