Page 1 of 1

Key press button simulation in nuBuilder

Posted: Sat Jun 15, 2019 8:15 am
by Janusz
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?

Re: Key press button simulation in nuBuilder

Posted: Sat Jun 15, 2019 9:14 am
by kev1n
Does this do the same?

Code: Select all

document.body.style.zoom = 1.5

Re: Key press button simulation in nuBuilder

Posted: Sat Jun 15, 2019 9:40 am
by Janusz
Thanks for reply.
This option is not fully equivallent - it does not resize forms inside the iframes.

Re: Key press button simulation in nuBuilder

Posted: Sat Jun 15, 2019 9:44 am
by Janusz
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.

Re: Key press button simulation in nuBuilder

Posted: Sat Jun 15, 2019 10:42 am
by kev1n
I would ask this question at stackoverflow.

Re: Key press button simulation in nuBuilder

Posted: Fri Jul 26, 2019 10:18 am
by admin
Janusz,

Try something like this...

Code: Select all

 $('body').css('transform','scale(2)');

Steven

Re: Key press button simulation in nuBuilder

Posted: Fri Jul 26, 2019 10:46 pm
by Janusz
Steven,
Yes it's working - thanks a lot.
to keep the upper left corner as reference the transform-origin can be added

Code: Select all

ex.
$('body').css('transform','scale(1.2)'); 
$('body').css('transform-origin','top left');

Re: Key press button simulation in nuBuilder

Posted: Mon Jul 29, 2019 12:50 am
by admin
Janusz ,

That's good to know.


Steven