shift-up/down arrow in list/table should add to selection

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

shift-up/down arrow in list/table should add to selection

Post by billworld » Mon Nov 03, 2008 10:06 pm

A user should be able to use the up/down arrows to navigate lists/tables and while holding down the shift key the selection should be added to.

This should work by default, but, doesn't.

Can it be coded in?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Mon Nov 03, 2008 10:24 pm

Hi Bill,

Yes, it can be done.

Code: Select all

on arrowKey theKey
   if the shiftkey is down then
      if theKey is down then
         put the hilitedLines of the selectedField into myLines
         if myLines is not empty then
            put comma & max(myLines)+1 after myLines
            set the hilitedLines of the selectedField to myLines
         end if
      else if theKey is up then
         put the hilitedLines of the selectedField into myLines
         if myLines is not empty and item 1 of myLines is not 1 then
            put max(1,min(myLines)-1) & comma before myLines
            set the hilitedLines of the selectedField to myLines
         end if
      end if
   else
      -- put there what you want to do if the
      -- shiftKey is up
      pass arrowKey
   end if
end arrowKey
This script works fine with a list field. You might need to tweak it a bit to make it work with your table field. Also, you might need to change selectedField with target, depending on what you do with the script exactly and where you keep it.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

Post by billworld » Tue Nov 04, 2008 12:04 am

Thanks Mark.
Mark wrote:Hi Bill,

Yes, it can be done.

Post Reply