Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Key press button simulation in nuBuilder

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
Janusz
nuBuilder Team
Posts: 508
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 10 times
Been thanked: 18 times

Key press button simulation in nuBuilder

Unread post 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?
If you like nuBuilder, please leave a review on SourceForge
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Key press button simulation in nuBuilder

Unread post by kev1n »

Does this do the same?

Code: Select all

document.body.style.zoom = 1.5
Janusz
nuBuilder Team
Posts: 508
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 10 times
Been thanked: 18 times

Re: Key press button simulation in nuBuilder

Unread post by Janusz »

Thanks for reply.
This option is not fully equivallent - it does not resize forms inside the iframes.
If you like nuBuilder, please leave a review on SourceForge
Janusz
nuBuilder Team
Posts: 508
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 10 times
Been thanked: 18 times

Re: Key press button simulation in nuBuilder

Unread post 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.
If you like nuBuilder, please leave a review on SourceForge
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: Key press button simulation in nuBuilder

Unread post by kev1n »

I would ask this question at stackoverflow.
admin
Site Admin
Posts: 2822
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 29 times

Re: Key press button simulation in nuBuilder

Unread post by admin »

Janusz,

Try something like this...

Code: Select all

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

Steven
Janusz
nuBuilder Team
Posts: 508
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 10 times
Been thanked: 18 times

Re: Key press button simulation in nuBuilder

Unread post 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');
If you like nuBuilder, please leave a review on SourceForge
admin
Site Admin
Posts: 2822
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 29 times

Re: Key press button simulation in nuBuilder

Unread post by admin »

Janusz ,

That's good to know.


Steven
Post Reply