Listfield Questions

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Listfield Questions

Tore Nilsen via use-livecode
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
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Listfield Questions

Tore Nilsen via use-livecode
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 <[hidden email]> 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
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Listfield Questions

Tore Nilsen via use-livecode
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 <[hidden email]> 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 <[hidden email]> 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
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Listfield Questions

Tore Nilsen via use-livecode
In reply to this post by Tore Nilsen via use-livecode


> On Jun 14, 2018, at 23:01 , Peter Bogdanoff via use-livecode <[hidden email]> 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

<snip>

I do a similar thing, popping up a list field with similar lines to what the user typed into another field, and allowing the user to arrow and select with return or spacebar. I use arrowKey.

Bob S

on mouseDown
   put the clickLine into theClickedLine
   put  value(theClickedLine) into theSalesPerson
   put theSalesPerson into field "fldSalesPerson"
   hide me
end mouseDown

on selectionChanged
   put the clickLine into theClickedLine
   put  value(theClickedLine) into theSalesPerson
   put theSalesPerson into field "fldSalesPerson"
   hide me
end selectionChanged

on openField
   put the hilitedLine of me into theHilitedLine
   put line theHilitedLine of the text of me into theSalesPerson
   put theSalesPerson into field "fldSalesPerson"
end openField

on returnInField
   put the hilitedLine of me into theHilitedLine
   put line theHilitedLine of the text of me into theSalesPerson
   put theSalesPerson into field "fldSalesPerson"
   hide me
end returnInField

on rawKeyDown pKey
   if pKey is 32 or pKey is 65289 then
      send returnInField to me in 0 seconds
   end if
   pass rawKeyDown
end rawKeyDown

on arrowKey pDirection
   switch pDirection
      case "up"
         if the hilitedLine of me >1 then set the hilitedLine of me to the hilitedLine of me -1
         break
      case "down"
         if the hilitedLine of me < the number of lines of the text of me then \
               set the hilitedLine of me to the hilitedLine of me +1
         break
   end switch
   
   put the hilitedLine of me into theHilitedLine
   put line theHilitedLine of the text of me into theSalesPerson
   put theSalesPerson into field "fldSalesPerson"
   pass arrowKey
end arrowKey

on exitField
   hide me
end exitField


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Listfield Questions

Tore Nilsen via use-livecode
In reply to this post by Tore Nilsen via use-livecode
Charles Szasz wrote:

 > Does anybody know how to script a listfield to hilite a line using
 > arrow keys on the keyboard?

That should be happening automatically whenever the field has focus.

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Listfield Questions

Tore Nilsen via use-livecode
In reply to this post by Tore Nilsen via use-livecode
Thanks Richard for your help. Unfortunately, using keyboard arrow keys may hilite a line but it does not put a value associated with the line into an input field.  

Sent from my iPad
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Listfield Questions

Tore Nilsen via use-livecode
A selectionChanged handler in the list field will take care of that.

Tore

> 16. jun. 2018 kl. 06:31 skrev Charles Szasz via use-livecode <[hidden email]>:
>
> Thanks Richard for your help. Unfortunately, using keyboard arrow keys may hilite a line but it does not put a value associated with the line into an input field.  
>
> Sent from my iPad
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Listfield Questions

Tore Nilsen via use-livecode
In reply to this post by Tore Nilsen via use-livecode
Charles Szasz wrote:
 > Thanks Richard for your help. Unfortunately, using keyboard arrow keys
 > may hilite a line but it does not put a value associated with the line
 > into an input field.

Yes, LC only handles the most common UI conventions.  Actions specific
to an app's design will of course need to be scripted.

So while you shouldn't need to script anything to have the arrow keys
navigate the selected line of a field, you can use the automatic
behavior provided to trap the selectionChanged message to copy the
hilitedText of the field into another field as needed.

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Listfield Questions

Tore Nilsen via use-livecode
In reply to this post by Tore Nilsen via use-livecode
More ideas/solution.

 ON arrowkey
  send postImage to me in 0 seconds
  pass arrowkey
END arrowkey


ON postImage
  put the hilitedline of fld "FileList" into gLastLine
  put the hilitedtext of fld "FileList"into fld "currentImage"
  showPhoto (the hilitedtext of fld "FileList")
END postImage


ON  mouseUp #in case you want to options
   IF (the hilite of btn "Reorder") THEN
      put word 2 of the clickline into gCapWriterLastLineHandled
   end if
   IF the optionkey = "down" THEN
      answer "Are you sure you want to delete" && the clicktext & "?" with "delete" and "no"
      if it is "no" then
         exit to top
      end if
      delete file (gCurrentSlideShowFolder& the clicktext)
      delete file (gCurrentSlideShowFolder & "/thumb/" & the clicktext)
      buildList gCurrentSlideShowFolder
      exit MouseUp
   END IF
   put the hilitedline of me into gLastLine
   showPhoto the clicktext
END mouseup



Brahmanathaswami
 

On 6/15/18, 6:31 PM, "use-livecode on behalf of Charles Szasz via use-livecode" <[hidden email] on behalf of [hidden email]> wrote:

    Thanks Richard for your help. Unfortunately, using keyboard arrow keys may hilite a line but it does not put a value associated with the line into an input field.  
   
   

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Listfield Questions

Tore Nilsen via use-livecode
In reply to this post by Tore Nilsen via use-livecode
Brahmanathaswami,

Thanks for tour script suggestion!  But I am not sure what it does!  You give postImage in the script.  Does this script have anything to with images?

Sent from my iPad
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode