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: 257
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: 359
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: 257
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: 257
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: 359
Joined: Mon Oct 15, 2018 2:13 am

Re: Key press button simulation in nuBuilder

Postby admin » Fri Jul 26, 2019 5:48 pm

Janusz,

Try something like this...

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



Steven
admin
Site Admin
 
Posts: 3162
Joined: Mon Jun 15, 2009 9:53 am

Re: Key press button simulation in nuBuilder

Postby Janusz » Sat Jul 27, 2019 6:16 am

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');
Janusz
 
Posts: 257
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: Key press button simulation in nuBuilder

Postby admin » Mon Jul 29, 2019 8:20 am

Janusz ,

That's good to know.


Steven
admin
Site Admin
 
Posts: 3162
Joined: Mon Jun 15, 2009 9:53 am


Return to Custom Code



cron