One of the columns is my DataGrid is called "Notes". The user can type in (a variable amount of) text in that cell. The width of the "Notes" column being narrow, the DataGrid cannot display the contents of the Note (except for the first word or two). It would be nice to have the contents of the cell displayed in a separate field when the user clicks in a cell in the "Notes" column.
I see that double-clicking a cell opens it for editing. Thus, I infer that a cell does recognize a mouse click. So, how/where do I script a single click?
Thanks for any help,
Sri.
DataGrid: Scripting mouse click in a cell
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 163
- Joined: Tue Jan 26, 2010 10:15 pm
- Contact:
Re: DataGrid: Scripting mouse click in a cell
Sri,
A possible solution is to add a mouseUp handler in the datagrid group script:
doSomething will only be executed if one clickes on a cell into the "Notes" column. Be sure to have data in the row to have something happening.
By anticipation, you will probably have the need to get the cell's content for displaying the corresponding text to update:
Here, we are using the custom property cIndex for storing the index of the clicked row in the datagrid. So, when the user will update the field, we will able to update the corresponding "Notes" cell in the datagrid.
Here is a possible script for the field "myNotesEditor"
For more informations about the datagrid keywords (dgColumn, dgIndex, dgDataControl, GetDataOfIndex, SetDataOfIndex and RefreshIndex) have a look to the datagrid API:
http://lessons.runrev.com/m/datagrid/l/ ... a-grid-api
Best,
A possible solution is to add a mouseUp handler in the datagrid group script:
Code: Select all
on mouseUp
if (the dgColumn of the dgDataControl of the target is "Notes") then
doSomething
end if
end mouseUp
By anticipation, you will probably have the need to get the cell's content for displaying the corresponding text to update:
Code: Select all
on mouseUp
local tTheIndex
if (the dgColumn of the dgDataControl of the target is "Notes") then
put the dgIndex of the target into tTheIndex
set the text of fld "myNotesEditor" to GetDataOfIndex(tTheIndex, "Notes")
set the cIndex of fld "myNotesEditor" to tTheIndex
end if
end mouseUp
Here is a possible script for the field "myNotesEditor"
Code: Select all
on closeField
dispatch "SetDataOfIndex" to grp "myDatagrid" with the cIndex of me, "Notes", the text of me
dispatch "RefreshIndex" to grp "myDatagrid" with the cIndex of me
pass closeField
end closeField
http://lessons.runrev.com/m/datagrid/l/ ... a-grid-api
Best,
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel
Re: DataGrid: Scripting mouse click in a cell
Hi TheSlug:
Thanks for the code. Works well!
I guess an alternative would be to edit the default column behavior of the specific column (here, "Notes") and add the following code:
Regards,
Sri.
Thanks for the code. Works well!
I guess an alternative would be to edit the default column behavior of the specific column (here, "Notes") and add the following code:
Code: Select all
on mouseUp
put the text of me into field "myNotesEditor"
end mouseUp
Sri.