cancel
Showing results for 
Search instead for 
Did you mean: 

Personas Slipstream - How to add functionality for the Enter key?

former_member238607
Participant

Hi,

We are running Personas 3.0 SP7.

Under the traditional rendering engine, I was able to add script like the following example to the onEnter screen event to handle events when the Enter key was pressed.

// Ignore the event if it wasn't fired by the Enter key.
if (triggerType !== source.EVENT_ENTER) return;


// If the Enter key was pressed inside a textbox, click a button.
if (focused && focused.id === session.findById("wnd[0]/usr/boxPersonas_149010509512345/txtPersonas_149434590467890").id){
    session.findById("wnd[0]/usr/btnPersonas_149019811223344").press();
  }

Under Slipstream, this code displays an error message saying "ReferenceError: triggerType is not defined".

If I remove the triggerType line of script, the code displays an error message saying "ReferenceError: focused is not defined".

I tried adding session.utils in front of triggerType and focused. The code no longer displays an error, but session.utils.triggerType and session.utils.focused both come back as 'undefined', so that is not a solution.

Does anyone know how to check if the Enter key was pressed, and determine which object had focus when it was, in Slipstream?

Thank you very much for your help!

Accepted Solutions (1)

Accepted Solutions (1)

clemens_gantert
Active Participant

Hello Jeff,

"triggerType" is not a defined parameter of the onEnter event. It's a parameter associated with the onBeforeRefresh event and I don't know why the WebGui would provide the parameter for the onEnter as well (it's definitively not an official parameter).

The "focused" parameter is defined for onEnter, but it must only be provided if there really is a focused control when the enter key is pressed. So you want to check for the parameter's presence in a safe way like:

if (typeof selected === 'object' ) ...

Also, recently defects were reported regarding onEnter in SE. Be sure you have the latest client note installed.

Best Regards,

Clemens

Answers (1)

Answers (1)

former_member238607
Participant
0 Kudos

Hi Clemens,

I'm not sure if I did something wrong, but using if (typeof selected === 'object') in the onEnter event does not seem to ever result in a true condition; at least not when Enter is pressed inside an Input Field control.

I was able to get the following code to work in the onEnter event.

if (typeof focused !== "object") return;  // Ignore the event if an object doesn't have focus.

// If the Enter key was pressed inside the Change Notification textbox, click the tile to fire the script.
if (focused.id === "wnd[0]/usr/txtPersonas_123456") {
  session.findById("wnd[0]/usr/subPersonas_654321/btnPersonas_112233").press();
}

Thanks for your help!

clemens_gantert
Active Participant
0 Kudos

Hello Jeff,

Your're absolutely right. My mistake. The focused parameter is of type boolean. So the script must be:

if (typeof focused !=='boolean') return;

Cheers,

Clemens