Hi,
I created an option button in a column of a DataGrid. OK, it reacts as I want.
I see there is a script for this option button with some handlers like "on FillInData pData", "on mouseDoubleUp pMouseBtnNum", .....
But how can I script this button to take an action when I click on it?
In a standard option menu, I can script this:
on mouseUp
... Take an action
end mouseUp
But this do not run on the button in the column DataGrid.
How can I do this?
Thanks
Template script for DataGrid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Template script for DataGrid
Hi guylouis,
read up here:
http://lessons.livecode.com/m/datagrid/ ... -s-columns
and here:
http://lessons.livecode.com/m/datagrid/ ... mns-part-2
Attention: Advanced stuff!
Best
Klaus
read up here:
http://lessons.livecode.com/m/datagrid/ ... -s-columns
and here:
http://lessons.livecode.com/m/datagrid/ ... mns-part-2
Attention: Advanced stuff!
Best
Klaus
Re: Template script for DataGrid
Hi guylouis:
1. The structure of Data grid is complicated. The option menu button you put in a column of a DG is inside a nested stream of groups. The long name of one of the buttons in the column, e.g., is
button "Option Menu" of group "MyColumnName 0001" of group "MyColumnName" of group "dgList" of group "dgListMask" of group "DataGrid 1" of card "DG-ButtonsMenusImages" of stack "MyStack"! That is, each button in a column is a different object. If you code one of them, others won't work the same way.
2. So, you have to script the object in the "row template". This is where you specified what should be there in each column (when you created a "table type" DG). Open the object inspector of the DataGrid, click on "Edit Row Template", click further to "Edit Group" until you can select the option button; now you can edit the script of the "template" of your object. Now, whatever you script will be inherited by all the buttons down the column.
3. In option menu buttons, use menuPick message to script its behavior (not mouseUp). The mouseUp message appears to be sent only when menuPick handler is not there. Try this experiment: Make an option menu button on a card (not inside a data grid). Script it as follows:
Test it; it works. Now add the menuPick handler to the script.
Test it; only menuPick is processed.
You can use message watcher to look at the messages that were sent.
Regards,
Sri
1. The structure of Data grid is complicated. The option menu button you put in a column of a DG is inside a nested stream of groups. The long name of one of the buttons in the column, e.g., is
button "Option Menu" of group "MyColumnName 0001" of group "MyColumnName" of group "dgList" of group "dgListMask" of group "DataGrid 1" of card "DG-ButtonsMenusImages" of stack "MyStack"! That is, each button in a column is a different object. If you code one of them, others won't work the same way.
2. So, you have to script the object in the "row template". This is where you specified what should be there in each column (when you created a "table type" DG). Open the object inspector of the DataGrid, click on "Edit Row Template", click further to "Edit Group" until you can select the option button; now you can edit the script of the "template" of your object. Now, whatever you script will be inherited by all the buttons down the column.
3. In option menu buttons, use menuPick message to script its behavior (not mouseUp). The mouseUp message appears to be sent only when menuPick handler is not there. Try this experiment: Make an option menu button on a card (not inside a data grid). Script it as follows:
Code: Select all
on mouseUp
put "mouseUp was received" into msg
end mouseUp
Code: Select all
on mouseUp
put "mouseUp was received" into msg
end mouseUp
on menuPick pChosenItem
put pChosenItem after msg
end menuPick
You can use message watcher to look at the messages that were sent.
Regards,
Sri
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Template script for DataGrid
Hi.
What everyone said.
I am only adding something here because new users often jump right into using a dataGrid because it seems like such a compact, good-looking and powerful tool.
It is.
But it is also its own world, quite "apart" from LiveCode, and requires its own learning curve, again, quite apart from LiveCode. All this is just to add my own caveat, as Klaus mentioned. If you can do what you need with "ordinary" controls and groups, I recommend you think about doing so. For example, might a table field serve as the core of what you need?
Otherwise, write back as often you like about your dataGrid journey. It is more than worthwhile becoming conversant with them, as long as the features they offer are needed.
The dataGrid API section will be invaluable.
Craig
What everyone said.
I am only adding something here because new users often jump right into using a dataGrid because it seems like such a compact, good-looking and powerful tool.
It is.
But it is also its own world, quite "apart" from LiveCode, and requires its own learning curve, again, quite apart from LiveCode. All this is just to add my own caveat, as Klaus mentioned. If you can do what you need with "ordinary" controls and groups, I recommend you think about doing so. For example, might a table field serve as the core of what you need?
Otherwise, write back as often you like about your dataGrid journey. It is more than worthwhile becoming conversant with them, as long as the features they offer are needed.
The dataGrid API section will be invaluable.
Craig
Re: Template script for DataGrid
Hi,
Thanks for all your answers. I have the solution to my problem.
I used "Data Grid Helper 2.5" and all is now fine.
Best, Guy
Thanks for all your answers. I have the solution to my problem.
I used "Data Grid Helper 2.5" and all is now fine.
Best, Guy