Listfield Questions

Peter Bogdanoff bogdanoff at me.com
Fri Jun 15 02:07:35 EDT 2018


Also look at the selectedLine in the dictionary for what to do with the currently hilited line.

Peter


> On Jun 14, 2018, at 11:01 PM, Peter Bogdanoff via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Charles, 
> This is from something that I’m doing where the user can use the arrow keys to hilite another line or even scroll the field (my field has hundreds of lines). Also as a bonus, pressing the enter or return keys on the keyboard will do the same as clicking on the line.
> 
> You probably would put this into the card script.
> 
> Peter Bogdanoff
> 
> 
> 
> # Catch the arrow, return, enter keys
> on rawKeyDown what
>   indexLineSelect what
> 
>   pass rawKeyDown
> end rawKeyDown
> 
> 
> on indexLineSelect tKey   
> # Currently hilited line
>   put the hilitedLine of field "GlossaryTerms" into tLine
> 
>   if tKey is "65293" or tKey is "65421"then
>      # Return or Enter
>      if tLine is not empty then
>         # Here you would do something based on the currently hilited line
>         #
>      end if
>      exit indexLineSelect
> 
>   else if tKey is "65362" then
>      # Arrowkey up
>      indexLineSelectChange up
>      exit indexLineSelect
> 
>   else if tKey is "65364" then
>      # Arrowkey down
>      indexLineSelectChange down
>      exit indexLineSelect
>   end if
> 
> 
> on indexLineSelectChange which
> # This does the actual change of the hilited line
>   put the hilitedLine of field “YourFieldName" into tLine
>   if tLine is not empty then
>      if which is "up" then
>         if (tLine - 1) > 0 then # Don’t want to go below line zero
>            set the hilitedLine of field "GlossaryTerms" to (tLine - 1)
>         end if
>      else
>         if (tLine + 1) < the number of lines of field "GlossaryTerms" then
>            set the hilitedLine of field "GlossaryTerms" to (tLine + 1)
>         end if
>      end if
>   else
>     # Optional--This will scroll the field when there is no hilited line yet
>      if which is "up" then
>         set the scroll of field "GlossaryTerms" to the scroll of field "GlossaryTerms" - 40
>      else
>         set the scroll of field "GlossaryTerms" to the scroll of field "GlossaryTerms" + 40
>      end if
>   end if
> end indexLineSelectChange
> 
> 
> 
> 
> 
> 
>> On Jun 14, 2018, at 9:30 PM, Charles Szasz via use-livecode <use-livecode at lists.runrev.com> wrote:
>> 
>> Does anybody know how to script a listfield to hilite a line using arrow keys on the keyboard?   Also, how do you save a hilited line in a listfield?
>> 
>> Sent from my iPad
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the Use-livecode mailing list