Add an event to a dynamically declared control

This is a PowerBuilder question. I am using PowerBuilder 12 Classic.

I have a window in which most controls are declared dynamically in code using OpenUserObject. When one of these controls is clicked, a panel should open in the container window. However, I'm not sure how to trigger an event from a dynamically declared control. The control type is customizable (custom code in a standard visual object, singleLineEdit), and I have custom code declared in the getfocus control event. But how can I refer to the container window?

I know that I can refer to the container window by name, but this is self-limiting. Is there any other way to do this?

+3
source share
3 answers

If you do not need to pass arguments, you can use parent.triggerEvent("event_name")to trigger events in a window. If events or functions are defined in the ancestor of the window (for example, as PFC), you can apply parentto the type of the ancestor and call directly. An example of using PFC:

w_master w_container

w_container = parent
w_container.of_SetUpdateObjects({this})
+2
source

Use parent.dynamic from the custom GetFocus object event. The parent keyword will refer to the container of the control, and using the dynamic keyword will allow you to call any user-defined functions or events in the container. For instance:

parent.dynamic uf_OpenPanel(ls_SomeArg)
+1
source

, , , . dynamic "window"

, (, tab → datawindow), , , , , - .

, , , :

lw

lw = iuo_customcontrol.uf_setparent ()

/: : iw_parentwindow

: uf_setparent ( as_window): iw_parentwindow = as_window

,

iw_parentwindow.EVENT dynamic ue_retrieve() iw_parentwindow.dynamic wf_retrieve()

+1

Source: https://habr.com/ru/post/1766457/


All Articles