Key press button simulation in nuBuilder

Questions related to customising nuBuilder Forte with Javascript or PHP.

Key press button simulation in nuBuilder

Postby Janusz » Sat Jun 15, 2019 3:45 pm

Hi,
I wanted to implement equivallent of the CRTL + / - key press in Chrome as buttons in nuBuilder (Chrome zoom in /out)
so trying to implement some function as in the following link:
https://blog.softhints.com/java-robot-k ... and-click/

I prepared the function placed in custome code JS:
Code: Select all
public static void zoom_plus(Robot r){
    r.keyPress(KeyEvent.VK_CONTROL);
    r.keyPress(KeyEvent.VK_PLUS);
    r.delay(1000);
    r.keyRelease(KeyEvent.VK_CONTROL);
    r.keyRelease(KeyEvent.VK_PLUS);
}

and later in button onclick I am trying to run it with: zoom_plus();
but does not work with following error:
Code: Select all
Uncaught TypeError: Cannot read property 'keyPress' of undefined
    at zoom_plus (<anonymous>:61:7)
    at HTMLInputElement.onclick (index.php:1)

Do you you have some suggestions how to progress with it?
Janusz
 
Posts: 179
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: Key press button simulation in nuBuilder

Postby kev1n » Sat Jun 15, 2019 4:44 pm

Does this do the same?

Code: Select all
document.body.style.zoom = 1.5
kev1n
 
Posts: 191
Joined: Mon Oct 15, 2018 2:13 am

Re: Key press button simulation in nuBuilder

Postby Janusz » Sat Jun 15, 2019 5:10 pm

Thanks for reply.
This option is not fully equivallent - it does not resize forms inside the iframes.
Janusz
 
Posts: 179
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: Key press button simulation in nuBuilder

Postby Janusz » Sat Jun 15, 2019 5:14 pm

checking more - it cloud be solution - but then I would need to set it up for main window and all iframes.

the CRTL + / - is setting it for for all objects in the window.
Janusz
 
Posts: 179
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: Key press button simulation in nuBuilder

Postby kev1n » Sat Jun 15, 2019 6:12 pm

I would ask this question at stackoverflow.
kev1n
 
Posts: 191
Joined: Mon Oct 15, 2018 2:13 am


Return to Custom Code



cron