LiveCode Lessons (copy)Data GridData Grid Tips & TricksGeneralHow Do I Find Out Which Line The Mouse Is Over?

How Do I Find Out Which Line The Mouse Is Over?

Each data grid row has a dgDataControl property that returns the long id of the control. Each control also has a dgLine and dgIndex property. You can combine the two in order to get the control the mouse is over.

 

put the dgDataControl of the mousecontrol into theControl 
if theControl is not empty then  
   put the dgLine of theControl into theLineNo 
end if

3 Comments

Mark Stuart

Where do I put this script so that I can return the values in the row as the mouse enters each row? I'd like to do a "popout" of the data in each row and put that data into this "popout" as it moves over each row. The popout would appear (with the contents of the row below it) when entering the row and close as it leaves the row. This would do the same for each row entered with the mouse over. Something I saw on TV - pretty cool.

Trevor DeVore

You could put this script in the data grid group script.

One issue you will need to take into account is that the engine doesn't allow you to capture mouseEnter/Leave events for a group as a whole. You only get mouseEnter/mouseLeave events for every control in the group. This makes it difficult to know when the mouse is entering/leaving a custom control like a row.

Roger Kingston

This works for me in the DataGrid script without any errors and is quite nifty if you have cells that are overflowing. You can adopt what you do with the lvText variable as you please:
on mouseMove
if the mouseControl is not empty then
put the short name of the mouseControl into lvTarget
put the last word of lvTarget into lvLine
put word 2 of lvTarget into lvItem
if lvItem is a number and lvLine is a number then
set the itemDel to tab
put item lvItem of line lvLine of the dgText of me into lvText
set the toolTip of field lvTarget to lvText
end if
end if
end mouseMove

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.