Disable built-in 'enter' shortcut in struct table

Hello,
I saw that ‘enter’ key works on table as ‘select next item’. Thats nice in most of cases, but how can i add to that additional script? I tried to create my own shortcut on ‘enter’ key and trigger function with it, so while table not in focus itsworks, but if i work on table, the priority of built-in shortcut is higher, and my script doesnt triggered.
Is there a way to disable that/ or add to that shorcut scripting ?
Thanks,

Alex.

?

#DashBoard

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

Hello Ben,

Thanks for that one - event.getKeyChar()! I checked it now , this is exactly what I need - I want to assign ‘play’ command to ‘enter’ press, so when it pressed, play() function should be fired with current selected video id, before the selection changed. In debug - if I press enter - I see that I get the current selection. So this is exactly what I need. And then selection is advanced, to next video id row. So, no need to mess with delayed executions.

Thank you!

Alex.

#DashBoard