Page 1 of 1
help using pui.click() in the onclick element
Posted: Mon Aug 11, 2014 10:52 am
by drp2thehill
I'm trying to use pui.click() in the onclick property for multiple screen elements. What I need is to understand how, if the user 'clicks' on any of these elements,
to get the underlying RPG program to 'know' the element has been clicked, so I can load screen #2 and display the info associated with this group of elements.
Also, if I setup a different set of elements using onclick with pui.click, how do you distinguish this set from the previous set on the same screen?
Re: help using pui.click() in the onclick element
Posted: Mon Aug 11, 2014 12:16 pm
by dieter
We had the same problem. We solved this by setting a hidden field on the screen by Javascript.
E.g. if you want to get the onclick on an image on you screen, your code is now:
pui.click();
But you can do the following:
Put a hidden field (e.g. a hidden textbox) onto your screen.
Give the textbox a special id, e.g. "txtWidget".
Bind a RPG variable to that textbox, e.g. "xx_widget" char(40).
The put the following code in your onclick event:
changeElementValue("txtwidget","myImage1");
pui.click();
Now after the exfmt the RPG variable xx_widget has the value "myImage1".
Dieter
Re: help using pui.click() in the onclick element
Posted: Mon Aug 11, 2014 12:27 pm
by dieter
Just an addition to my post:
Of cource you can set more than one variable with JavaScript. So you also can create a second hidden textbox e.g. named "txtEvent". With
Code: Select all
changeElementValue("txtEvent","onclick");
you can give the information, which event was triggered, to your program. So you can catch multiple events on your widget in your RPG program:
Code: Select all
exfmt fmt1;
select;
when xx_widget = 'myImage1' and xx_event = 'onclick';
do_something();
when xx_widget = 'myImage1' and xx_event = 'ondblclick';
do_another_thing();
...
Re: help using pui.click() in the onclick element
Posted: Tue Aug 12, 2014 12:12 pm
by DaveLClarkI
drp2thehill wrote:I'm trying to use pui.click() in the onclick property for multiple screen elements. What I need is to understand how, if the user 'clicks' on any of these elements,
to get the underlying RPG program to 'know' the element has been clicked, so I can load screen #2 and display the info associated with this group of elements.
The intended means for notifying your RPG program that a particular widget (an image or a button, for example) has been clicked does not require that you use the
onclick event (a.k.a., property) at all -- nor any additional hidden textbox-type widgets. Rather, the intent is that you simply bind the widget's
response property to an RPG indicator field. (If you use a named indicator this field is defined as a 1-byte character.) Then, when the user clicks on that widget, the bound response indicator is turned on and your RPG program can easily test for that. No
pui.click() is required to make all this happen.
Re: help using pui.click() in the onclick element
Posted: Wed Aug 13, 2014 4:42 am
by dieter
Hello Dave,
of course you are right. Most widgets have a response attribute which can directly be catched by a bound field. I thought the question was how to catch a click event of a widget which has not such a response attribute, e.g. a label.
Dieter
Re: help using pui.click() in the onclick element
Posted: Tue Sep 30, 2014 5:28 pm
by drp2thehill
Sorry, Thanks to both Dieter and Dave for those answers!