Search code examples
javascriptpowerbuilderole

Javascript event callback to PowerBuilder with data


I am using PowerBuilder 2017 and have created an OLE control (Microsoft Web Browser) with a local html file using Leaflet JS.

When a user clicks on a marker on the leaflet map I would like a reference value (coordinates) sent back to PowerBuilder where the code there can react to the user event.

My question is how can I get a javascript event to also trigger an event in the main PowerBuilder application?


Solution

  • After a lot of investigating I have managed to solve my problem, I added the following code into PowerBuilder, inside the OLE Control's click event:

    oleobject lole_data
    string ls_innertext, ls_classname
    
    lole_data = This.Object.Document.ActiveElement
    
    if not IsNull(lole_data) then
    
        ls_classname = Lower( string(This.Object.Document.ActiveElement.classname)) 
        if ls_classname = "leaflet-popup-content" then  
            ls_innertext = string(lole_data.parentNode.InnerText)
        end if  
    
    end if
    

    ActiveElement is the method to use. I obtain the Leaflet class and can identify it is in fact a Marker PopUp that was clicked.