Page 1 of 1

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

Posted: Sun Mar 14, 2021 6:11 am
by liveme
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:

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

Posted: Sun Mar 14, 2021 9:58 am
by liveme
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:

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

Posted: Sun Mar 14, 2021 12:49 pm
by stam
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...

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

Posted: Sun Mar 14, 2021 2:46 pm
by Klaus
Yes, what stam said!

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

Posted: Sun Mar 14, 2021 11:37 pm
by jameshale
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.

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

Posted: Mon Mar 15, 2021 5:26 am
by liveme

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:

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

Posted: Mon Mar 15, 2021 5:32 am
by liveme
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: