Page 1 of 1

Key press button simulation in nuBuilder

PostPosted: Sat Jun 15, 2019 3:45 pm
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

PostPosted: Sat Jun 15, 2019 4:44 pm
by kev1n
Does this do the same?

Code: Select all
document.body.style.zoom = 1.5

Re: Key press button simulation in nuBuilder

PostPosted: Sat Jun 15, 2019 5:10 pm
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

PostPosted: Sat Jun 15, 2019 5:14 pm
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

PostPosted: Sat Jun 15, 2019 6:12 pm
by kev1n
I would ask this question at stackoverflow.

Re: Key press button simulation in nuBuilder

PostPosted: Fri Jul 26, 2019 5:48 pm
by admin
Janusz,

Try something like this...

Code: Select all
$('body').css('transform','scale(2)');



Steven

Re: Key press button simulation in nuBuilder

PostPosted: Sat Jul 27, 2019 6:16 am
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

PostPosted: Mon Jul 29, 2019 8:20 am
by admin
Janusz ,

That's good to know.


Steven