[Gambas-user] Calling a sub from a Webview

terco IDE tercoide at ...67...
Thu Dec 5 00:34:57 CET 2013


Hi:
i'm the mad guy who made that VB code wich calls Funcitions from the HTML code :)

I'n new  to Gambas, but from what I've read, it is possible to set up an Object Observer ...so why not intercept the webview control  and do  things BEFORE the Click event takes place?

Saludos
Martin

> From: gambas-user-request at lists.sourceforge.net
> Subject: Gambas-user Digest, Vol 91, Issue 10
> To: gambas-user at lists.sourceforge.net
> Date: Wed, 4 Dec 2013 22:34:03 +0000
> 
> Send Gambas-user mailing list submissions to
> 	gambas-user at lists.sourceforge.net
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	https://lists.sourceforge.net/lists/listinfo/gambas-user
> or, via email, send a message with subject or body 'help' to
> 	gambas-user-request at lists.sourceforge.net
> 
> You can reach the person managing the list at
> 	gambas-user-owner at lists.sourceforge.net
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Gambas-user digest..."
> 
> 
> Today's Topics:
> 
>    1. Re: New to this list (Wolfgang)
>    2. Re: New to this list (Fabien Bodard)
>    3. Re: Selecting a window (Fabien Bodard)
>    4. Calling a sub from a Webview (Jesus)
>    5. Re: Calling a sub from a Webview (Tobias Boege)
>    6. Re: Calling a sub from a Webview (Jesus)
>    7. Re: Calling a sub from a Webview (Tobias Boege)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Wed, 04 Dec 2013 19:56:14 +0100
> From: Wolfgang <dl7nb at ...17...>
> Subject: Re: [Gambas-user] New to this list
> To: willy at ...2734..., 	mailing list for gambas users
> 	<gambas-user at lists.sourceforge.net>
> Message-ID: <529F7ACE.9090906 at ...17...>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Hi Willy,
> 
> Thank you very much for the quick answer. (wow, as I can see in "abt 
> Gambas" you're a "big one" ;-)
> ....
>   That was exactly what I tried. An I tried it with many different .png 
> images of all sizes.
> It shows up in Project->Properties, but it did not work! I still have 
> that funny toolbox for both the packager and the app.
> 
> The same happens when I use the example projects. Their 
> Project-properties show different icons. But the *.deb packages all 
> produce these toolbox-icons.
> 
> The Icons for all my forms show the right Icons as I have defined in the 
> Form.property!
> 
> Are there rules for the .png files???
> 
> I forgot in 1st post: I am using Gambas 3.5.1
> 
> What am I doing wrong?? Or did I find something special???
> 
> Wolf
> 
> Hi Wolf,
> Welcome to the list. If you go to your project properties (menu Project 
> -> Properties), you can click on the Gambas icon on tab General and 
> browse for a .png image that will become your projects icon. This icon 
> will then be used to represent your application and used by the packager 
> as well.
> 
> Kind regards, Willy (aka gbWilly)
> 
> http://gambasshowcase.org/ http://howtogambas.org http://gambos.org 
> ------------------------------------------------------------------------------ 
> Sponsored by Intel(R) XDK Develop, test and display web and hybrid apps 
> with a single code base. Download it for free now! 
> http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk 
> _______________________________________________ Gambas-user mailing list 
> Gambas-user at lists.sourceforge.net 
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> 
> 
> 
> ------------------------------
> 
> Message: 2
> Date: Wed, 4 Dec 2013 20:16:03 +0100
> From: Fabien Bodard <gambas.fr at ...626...>
> Subject: Re: [Gambas-user] New to this list
> To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
> Message-ID:
> 	<CAFkCsL6e51BqTdCX+d7zWg09sy_doe4XZ=GJQ5XFs=r9eCNLTQ at ...627...>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> I'm not sure the packager initialize correctly the *.desktop file ...
> I need to test
> 
> 2013/12/4 Wolfgang <dl7nb at ...17...>:
> > Hi Willy,
> >
> > Thank you very much for the quick answer. (wow, as I can see in "abt
> > Gambas" you're a "big one" ;-)
> > ....
> >   That was exactly what I tried. An I tried it with many different .png
> > images of all sizes.
> > It shows up in Project->Properties, but it did not work! I still have
> > that funny toolbox for both the packager and the app.
> >
> > The same happens when I use the example projects. Their
> > Project-properties show different icons. But the *.deb packages all
> > produce these toolbox-icons.
> >
> > The Icons for all my forms show the right Icons as I have defined in the
> > Form.property!
> >
> > Are there rules for the .png files???
> >
> > I forgot in 1st post: I am using Gambas 3.5.1
> >
> > What am I doing wrong?? Or did I find something special???
> >
> > Wolf
> >
> > Hi Wolf,
> > Welcome to the list. If you go to your project properties (menu Project
> > -> Properties), you can click on the Gambas icon on tab General and
> > browse for a .png image that will become your projects icon. This icon
> > will then be used to represent your application and used by the packager
> > as well.
> >
> > Kind regards, Willy (aka gbWilly)
> >
> > http://gambasshowcase.org/ http://howtogambas.org http://gambos.org
> > ------------------------------------------------------------------------------
> > Sponsored by Intel(R) XDK Develop, test and display web and hybrid apps
> > with a single code base. Download it for free now!
> > http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
> > _______________________________________________ Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> >
> > ------------------------------------------------------------------------------
> > Sponsored by Intel(R) XDK
> > Develop, test and display web and hybrid apps with a single code base.
> > Download it for free now!
> > http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> 
> 
> -- 
> Fabien Bodard
> 
> 
> 
> ------------------------------
> 
> Message: 3
> Date: Wed, 4 Dec 2013 20:18:50 +0100
> From: Fabien Bodard <gambas.fr at ...626...>
> Subject: Re: [Gambas-user] Selecting a window
> To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
> Message-ID:
> 	<CAFkCsL5d6wZ061K6NkBSR0zSVCFowPuMQ4aQZUyHnG0bseVFCA at ...627...>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> I'm sure to understand what you want to achieve ... what do you mean
> by select a windows ?
> 
> 2013/12/4 John Rose <john.aaron.rose at ...626...>:
> > I want the user to be able to click a point within one of the windows
> > displayed on the desktop (i.e. not just Gambas forms) in order to select
> > that window. The code below shows how to access properties of all windows:
> > Dim dWindow As DesktopWindow = Null
> > Desktop.Windows.Refresh()
> > For Each dWindow In Desktop.Windows
> >    If dWindow.Minimized = False Then
> >       Print "Window: Name=" & dWindow.Name & ", " & "X=" & dWindow.X &
> > ", Y=" & dWindow.Y & ", " & "Width=" & dWindow.Width & ", Height=" &
> > dWindow.Height
> >    Endif
> > Next
> >
> > The only way I've thought of is to define a transparent form covering
> > the whole desktop with an associated mouse click event, which supplies
> > the co-ordinates of the point clicked. Then by examination of each
> > dWindow property (i.e. X, Y, Width, Height), one can determine which
> > window has been clicked. Is that the best way? But how can one allow for
> > the situation where the user has clicked a point which is within 2
> > windows i.e. is there a property of dWindow which shows if that window
> > is the 'top' one (i.e. covering the other one at that point)?
> >
> >
> >
> > ------------------------------------------------------------------------------
> > Sponsored by Intel(R) XDK
> > Develop, test and display web and hybrid apps with a single code base.
> > Download it for free now!
> > http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> 
> 
> -- 
> Fabien Bodard
> 
> 
> 
> ------------------------------
> 
> Message: 4
> Date: Wed, 04 Dec 2013 22:23:56 +0100
> From: Jesus <ea7dfh at ...2382...>
> Subject: [Gambas-user] Calling a sub from a Webview
> To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
> Message-ID: <529F9D6C.508 at ...2382...>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Hi all
> 
> I currently helping to port a VB6 program to Gambas3, but to my 
> surprise, it does weird things like these from the post title: it is 
> calling methods and functions from the html code inside a webbrowser 
> control.
> 
> It has a wb control that acts like a sort of wizard/help thing, and the 
> html links in that view are calling methods inside the application. That 
> links are as '<a href="act:some_class.method">some action</a>'
> 
> So the question is, could it be done with gambas somehow?
> 
> Regards
> -- 
> Jesus Guardon
> 
> 
> 
> ------------------------------
> 
> Message: 5
> Date: Wed, 4 Dec 2013 22:32:45 +0100
> From: Tobias Boege <taboege at ...626...>
> Subject: Re: [Gambas-user] Calling a sub from a Webview
> To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
> Message-ID: <20131204213245.GF509 at ...2774...>
> Content-Type: text/plain; charset=us-ascii
> 
> On Wed, 04 Dec 2013, Jesus wrote:
> > Hi all
> > 
> > I currently helping to port a VB6 program to Gambas3, but to my 
> > surprise, it does weird things like these from the post title: it is 
> > calling methods and functions from the html code inside a webbrowser 
> > control.
> > 
> > It has a wb control that acts like a sort of wizard/help thing, and the 
> > html links in that view are calling methods inside the application. That 
> > links are as '<a href="act:some_class.method">some action</a>'
> > 
> > So the question is, could it be done with gambas somehow?
> > 
> > Regards
> > -- 
> > Jesus Guardon
> 
> Jesus (meant as an interjection)! I know I shouldn't question other people's
> design choices but this is just mad. Actually it might have seemed like an
> elegant way to communicate with an HTML page to the original author of that
> program - I understand that - but this is just asking for trouble, IMHO.
> 
> However, I guess Object.Call() is your best bet here.
> 
> Regards,
> Tobi
> 
> 
> 
> ------------------------------
> 
> Message: 6
> Date: Wed, 04 Dec 2013 22:52:45 +0100
> From: Jesus <ea7dfh at ...2382...>
> Subject: Re: [Gambas-user] Calling a sub from a Webview
> To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
> Message-ID: <529FA42D.30904 at ...2382...>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> El 04/12/13 22:32, Tobias Boege escribi?:
> > On Wed, 04 Dec 2013, Jesus wrote:
> >> Hi all
> >>
> >> I currently helping to port a VB6 program to Gambas3, but to my
> >> surprise, it does weird things like these from the post title: it is
> >> calling methods and functions from the html code inside a webbrowser
> >> control.
> >>
> >> It has a wb control that acts like a sort of wizard/help thing, and the
> >> html links in that view are calling methods inside the application. That
> >> links are as '<a href="act:some_class.method">some action</a>'
> >>
> >> So the question is, could it be done with gambas somehow?
> >>
> >> Regards
> >> --
> >> Jesus Guardon
> >
> > Jesus (meant as an interjection)! I know I shouldn't question other people's
> > design choices but this is just mad. Actually it might have seemed like an
> > elegant way to communicate with an HTML page to the original author of that
> > program - I understand that - but this is just asking for trouble, IMHO.
> >
> > However, I guess Object.Call() is your best bet here.
> >
> > Regards,
> > Tobi
> >
> 
> Hi Tobi, thanks for reply
> 
> I am at your side about some (mad) practices, but...
> 
> I think Object.Call is suitable for calling or executing code inside or 
> outside of the current class, but not the other way round, IIUC. How 
> could I execute Object.Call from inside a webview? None of the events 
> webview exposes are suitable for doing this IMO, since the webview.url 
> is a property, not a method.
> 
> I will experiment, thanks for the tip!
> 
> Regards
> -- 
> Jesus Guardon
> 
> 
> 
> ------------------------------
> 
> Message: 7
> Date: Wed, 4 Dec 2013 23:33:23 +0100
> From: Tobias Boege <taboege at ...626...>
> Subject: Re: [Gambas-user] Calling a sub from a Webview
> To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
> Message-ID: <20131204223323.GG509 at ...2774...>
> Content-Type: text/plain; charset="us-ascii"
> 
> On Wed, 04 Dec 2013, Jesus wrote:
> > El 04/12/13 22:32, Tobias Boege escribi?:
> > > On Wed, 04 Dec 2013, Jesus wrote:
> > >> Hi all
> > >>
> > >> I currently helping to port a VB6 program to Gambas3, but to my
> > >> surprise, it does weird things like these from the post title: it is
> > >> calling methods and functions from the html code inside a webbrowser
> > >> control.
> > >>
> > >> It has a wb control that acts like a sort of wizard/help thing, and the
> > >> html links in that view are calling methods inside the application. That
> > >> links are as '<a href="act:some_class.method">some action</a>'
> > >>
> > >> So the question is, could it be done with gambas somehow?
> > >>
> > >> Regards
> > >> --
> > >> Jesus Guardon
> > >
> > > Jesus (meant as an interjection)! I know I shouldn't question other people's
> > > design choices but this is just mad. Actually it might have seemed like an
> > > elegant way to communicate with an HTML page to the original author of that
> > > program - I understand that - but this is just asking for trouble, IMHO.
> > >
> > > However, I guess Object.Call() is your best bet here.
> > >
> > > Regards,
> > > Tobi
> > >
> > 
> > Hi Tobi, thanks for reply
> > 
> > I am at your side about some (mad) practices, but...
> > 
> > I think Object.Call is suitable for calling or executing code inside or 
> > outside of the current class, but not the other way round, IIUC. How 
> > could I execute Object.Call from inside a webview? None of the events 
> > webview exposes are suitable for doing this IMO, since the webview.url 
> > is a property, not a method.
> > 
> > I will experiment, thanks for the tip!
> > 
> 
> Ahh, I got you wrong apparently... My answer can be applied if you have any
> occasion (event) to parse an (X)HTML element for this special attribute
> href="act:some_class.method". Then you can extract the class and method name
> and use Object.Call().
> 
> You can (ab)use the WebView's Click event like this: Modify the <a> element
> to look like this:
> 
> <a href="#act:some_class.method">some action</a>
> 
> Then, when clicked, the WebView will load the valid URL (the anchor sign had
> to be prepended to make it valid - to trigger the Click event, in turn) and
> provide you a WebFrame object in whose Url property you have the wanted
> act:some_class.method string somewhere. Now parse and execute.
> 
> I think it's too late for me to find clear words, so I attach a minimal
> example. (Note that the code is executed twice in this project which is
> certainly not desirable. You'll sure find a way to prevent this yourself.)
> 
> Regards,
> Tobi
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: execute-code-from-webview-0.0.1.tar.gz
> Type: application/octet-stream
> Size: 5313 bytes
> Desc: not available
> 
> ------------------------------
> 
> ------------------------------------------------------------------------------
> Sponsored by Intel(R) XDK 
> Develop, test and display web and hybrid apps with a single code base.
> Download it for free now!
> http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
> 
> ------------------------------
> 
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> 
> End of Gambas-user Digest, Vol 91, Issue 10
> *******************************************
 		 	   		  


More information about the User mailing list