Predictive text

All flavors welcome.
Forum rules
Be kind.
Post Reply
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Predictive text

Post by richmond62 »

I don't know how many people who read threads hereabouts also read threads 'thereabouts': but as I read threads in both places, and occasionally "do things" over there, I am now going to post hereabouts something I have just done thereabouts as I think it might be useful.

Stimulated by:

"I have a hidden text field which contains a list of my customers (it’s lengthy!). I have another field where a user types the name of the customer. I’d like my app to display a list of possible customers as the user types the name of the customer. I’d like it to work in the same way as typing something into the URL field of a web browser in that a field containing possible customers is displayed just below the text field the user is typing the customer in that the user can could click a customer name in the below field and have it populate the text field above. Ideally, the list field would dynamically resize itself vertically to show only the list of possible customers as the user types.

I’m not sure how to accomplish this. Can anyone provide some code on how to achieve this?"

and

"Hi Richmond,

Thank you the sample stack! Although it works, could you expand the code so that the list of customers updates accordingly when the user presses the delete/backspace key?"

------

Code: Select all

on keyUp 
   
end keyUp

on keyDown KP
   put KP after fld "ZZZ"
   put empty into fld "xlist"
   put fld "ZZZ" into XYZ
   put the number of chars in XYZ into KKK
   put 1 into LYNE
   repeat until line LYNE of fld "slist" is empty
      put char 1 to KKK of line LYNE of fld "slist" into ZLIST
      if ZLIST contains XYZ then
         put  line LYNE of fld "slist"  & cr after fld "xlist"
      end if
      add 1 to LYNE
   end repeat
end keyDown

on backspaceKey
   delete the last char of fld "ZZZ"
   put empty into fld "xlist"
   put fld "ZZZ" into XYZ
   put the number of chars in XYZ into KKK
   put 1 into LYNE
   repeat until line LYNE of fld "slist" is empty
      put char 1 to KKK of line LYNE of fld "slist" into ZLIST
      if ZLIST contains XYZ then
         put  line LYNE of fld "slist"  & cr after fld "xlist"
      end if
      add 1 to LYNE
   end repeat
end backspaceKey
-
Screenshot 2025-03-12 at 17.23.13.png
Screenshot 2025-03-12 at 17.23.13.png (164.86 KiB) Viewed 3950 times
Attachments
Predictivity.oxtstack
(2.15 KiB) Downloaded 74 times
https://richmondmathewson.owlstown.net/
User avatar
tperry2x
Posts: 3522
Joined: Tue Dec 21, 2021 9:10 pm
Location: webtalk.tsites.co.uk
Contact:

Re: Predictive text

Post by tperry2x »

I try to not read anything thereabouts when I aim to gather most things hereabouts. Mainly as I hope hereabouts may be around longer than thereabouts. :D

Anyway, is this not a duplicate of this topic? Not that it really matters of course.
Untitled.png
Untitled.png (43.62 KiB) Viewed 3905 times
User avatar
richmond62
Posts: 5288
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Predictive text

Post by richmond62 »

Not that I am aware of . . . although have spent most of the day dry-stane dyking in the garden I have not really been thinking about xTalk that much. 8-)
https://richmondmathewson.owlstown.net/
Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests