What command to detect any new activated line up or down a Datagrid ?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

What command to detect any new activated line up or down a Datagrid ?

Post by liveme » Sun Mar 14, 2021 6:11 am

Hi,
I need to execute a command each time a user activates a (single) new line upper or lower the present line within a Datagrid ?
(which usualy hilights the line in blue)

- does anyone knows which LC command do detect any of those moves ? :oops:
I tested

Code: Select all

on mouseUp
...but that s not the right one I guess

should be something similar to the idea of ;

Code: Select all

 "on new line activate"
do some stuff...

By moves , I mean all of these :
user would move cursor to activate a line using :
- keboard Arrows up/down
- mouse clic up/down
- Touchscreen direct clic onto another line (...latter on for the Android version, not very urgent)

Thanks :wink:

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

[solved] What command to detect any new activated line up or down a Datagrid ?

Post by liveme » Sun Mar 14, 2021 9:58 am

finahhhaahhhaly :!:

Code: Select all

on arrowKey theKey
   if theKey is "up" or theKey is "down" then 
   -- get yourself another beer !
   else pass arrowKey
end arrowKey
If you've found the hidden trick, up to you to hack this code :mrgreen:

stam
Posts: 2682
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: What command to detect any new activated line up or down a Datagrid ?

Post by stam » Sun Mar 14, 2021 12:49 pm

Must say i don't really understand what you're looking for liveme, although glad you found a solution that works for you...

However, are you looking for something like on selectionChanged pHilitedIndex, pPrevHilitedIndex ?
See more info here: https://livecode.fandom.com/wiki/Datagr ... ionChanged
*edited as link didn't work for some reason...
Last edited by stam on Sun Mar 14, 2021 2:49 pm, edited 1 time in total.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: What command to detect any new activated line up or down a Datagrid ?

Post by Klaus » Sun Mar 14, 2021 2:46 pm

Yes, what stam said!

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 474
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: What command to detect any new activated line up or down a Datagrid ?

Post by jameshale » Sun Mar 14, 2021 11:37 pm

If you look at the dictionary, Category:Objects:Datagrid you will see all the commands, messages and properties of the Datagrid.
I believe you are looking for the message “Selectionchanged”
From the dictionary…

Sent whenever the user changes the selection through some sort of user interaction.

Example

Code: Select all

on selectionChanged pHilitedIndex, pPrevHilitedIndex 
	put the dgDataOfIndex [ pHilitedIndex ] of me into theSelDataA 
	uiViewRecordOfID theSelDataA["id"] 
end selectionChanged
Description
Sent whenever the user changes the selection through some sort of user interaction. Handle this message in order to update your UI when the user makes a selection.

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

Re: What command to detect any new activated line up or down a Datagrid ?

Post by liveme » Mon Mar 15, 2021 5:26 am

Code: Select all

on selectionChanged
..maybe that will do the work too including all chaging means at once...will test it beside..
Tks for sharing
:idea: :wink:

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

Re: What command to detect any new activated line up or down a Datagrid ?

Post by liveme » Mon Mar 15, 2021 5:32 am

Hi Guys,

Thanks guys,

Code: Select all

on selectionChanged
is likely what I was looking for.*
*dont know if it will work on a Mobile device too but it works for changes made using keyboard or mouse, so quite cool !
:arrow:

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”