help using pui.click() in the onclick element

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
drp2thehill
Profound User
Posts: 23
Joined: Wed Aug 04, 2010 3:58 pm
First Name: Phillip
Last Name: Knox
Company Name: Lone Star Transportation, LLC
Phone: 817-230-0266
Address 1: 1100 Northway Dr.
City: Ft Worth
State / Province: Texas
Zip / Postal Code: 76131
Country: United States
Contact:

help using pui.click() in the onclick element

Post 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?
dieter
Experienced User
Posts: 122
Joined: Tue May 22, 2012 6:45 am
First Name: Dieter
Last Name: Schröder
Company Name: Ecclesia Holding GmbH
State / Province: Outside Canada/USA
Country: Germany
Contact:

Re: help using pui.click() in the onclick element

Post 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
dieter
Experienced User
Posts: 122
Joined: Tue May 22, 2012 6:45 am
First Name: Dieter
Last Name: Schröder
Company Name: Ecclesia Holding GmbH
State / Province: Outside Canada/USA
Country: Germany
Contact:

Re: help using pui.click() in the onclick element

Post 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();
 ...
DaveLClarkI
Experienced User
Posts: 165
Joined: Wed Dec 11, 2013 10:40 am
First Name: Dave
Last Name: Clark
Company Name: WinWholesale, Inc.
Phone: 937-294-5331
Address 1: 31101 Kettering Blvd.
City: Dayton
State / Province: Outside Canada/USA
Zip / Postal Code: 45439
Country: United States
Contact:

Re: help using pui.click() in the onclick element

Post 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.
dieter
Experienced User
Posts: 122
Joined: Tue May 22, 2012 6:45 am
First Name: Dieter
Last Name: Schröder
Company Name: Ecclesia Holding GmbH
State / Province: Outside Canada/USA
Country: Germany
Contact:

Re: help using pui.click() in the onclick element

Post 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
drp2thehill
Profound User
Posts: 23
Joined: Wed Aug 04, 2010 3:58 pm
First Name: Phillip
Last Name: Knox
Company Name: Lone Star Transportation, LLC
Phone: 817-230-0266
Address 1: 1100 Northway Dr.
City: Ft Worth
State / Province: Texas
Zip / Postal Code: 76131
Country: United States
Contact:

Re: help using pui.click() in the onclick element

Post by drp2thehill »

Sorry, Thanks to both Dieter and Dave for those answers!
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests