Hi Alex,
Sorry I did not respond earlier, I don’t know the answer off the top of my head. I had to do some research on this one.
I don’t know of any way to disable the “entry” key in tables. It seems to be built-in.
The way to add more code to this is to add a task to the selection parameter. If you use w.selectionparam as a config option for your table, you can point it to a parameter that will hold the value of the selected row in the table (for structured parameters).
You can then add a task to that parameter. I.e. drop it in your panel, and add a task. When the table selection changes, that task triggers. Now that will trigger no matter if you change it with enter or if you change it in some other way (mouse clicks, etc). So it’s not exactly the same. I made an example panel, which simply outputs a debug message when the selection changes. The code is at the bottom of this post.
I also gave my table an ID and added an “ogscript” block that triggers onKeyPress for that ID.
That tells me when Enter was pressed in the table, and I can do other stuff before the selection changes. If I want to do stuff after the selection changes, you have to use ogscript.asyncExec, and wait a little bit (I waited 20 ms). I hate those types of things though, because on some systems, the wait time may be bigger. So you have to be really careful about using those types of methods where you are waiting a specific amount of time. I prefer the method where you attach a task to the selection parameter. That one does not rely on some “magic number” timing.
Here is the code:
function doAfter() {
ogscript.debug("before: " + ogscript.getObject("current"));
ogscript.debug("20ms later " + params.getValue("Selection",0));
}
if (event.getKeyChar() == “10”) {
ogscript.debug("Enter was pressed selection is " + params.getValue(“Selection”, 0));
ogscript.putObject(“current”, params.getValue(“Selection”,0));
ogscript.asyncExec(doAfter,20);
}
Selection
ClipName
Director
var newValue = {
ClipName: "",
Director: "",
OriginalAirDate: "",
Author: ""
}
var p = params.getParam(‘params.clipList’, 0);
p.setValueAt(p.getElementCount(), newValue);
/*! block id=1014,1016,1015 !*/
ogscript.debug(("selection has changed to " + params.getValue('Selection', 0)));
/*!!
!!*/
/*!!77b645c16febcd859ce0239521416234!!*/
var selection = params.getValue('Selection', 0);
if (selection < 0)
{
return;
}
var newValue = new Array();
var clipList = params.getParam(‘params.clipList’, 0);
for (var i = 0; i < clipList.getElementCount(); i++)
{
if (i != selection)
{
newValue.push(clipList.getValueAt(i));
}
}
params.setAllValues(‘params.clipList’, newValue);
Director, Author
ClipName
Director
#DashBoard