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

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

Post 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:
liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm

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

Post 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:
stam
Posts: 3209
Joined: Sun Jun 04, 2006 9:39 pm

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

Post 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...
Last edited by stam on Sun Mar 14, 2021 2:49 pm, edited 1 time in total.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

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

Post by Klaus »

Yes, what stam said!
jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 494
Joined: Thu Sep 04, 2008 6:23 am

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

Post 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.
liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm

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

Post 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:
liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm

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

Post 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:
Post Reply