cloudtrends / open-webkit-sharp

Automatically exported from code.google.com/p/open-webkit-sharp
GNU Lesser General Public License v3.0
4 stars 1 forks source link

implement a click event for webkit browser #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. how to implement a click event in a webkit browser.
2. for example, if google page is displayed in the webkit browser and now a 
click on google search button to be implemented >
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by gyanesh...@gmail.com on 11 Oct 2011 at 10:41

GoogleCodeExporter commented 9 years ago
WebKit doesn't provide a Click() event, just a Right Click event. I will see if 
I can do something and will inform you.

Original comment by tsumalis96@gmail.com on 11 Oct 2011 at 3:45

GoogleCodeExporter commented 9 years ago
thx for ur quick response. could u pls check any other alternative to provide 
the code thru click  any button functionality. i will be eagerly waiting for ur 
reply. thx in advance

Original comment by gyanesh...@gmail.com on 12 Oct 2011 at 7:05

GoogleCodeExporter commented 9 years ago
I will try to implement a click event for 1.8 (or at least for 1.9)

Original comment by tsumalis96@gmail.com on 12 Oct 2011 at 7:51

GoogleCodeExporter commented 9 years ago
Hello Sir,

Firstly, thanks for launching such a great product. I am using it for my 
application, and it seem to be a solution to all my problems. Only issue that i 
faced is; if i want to click on any html tag (be it input, div, span), i 
couldn't find any method to do so? I was looking for something like 
InvokeMember available in default web browser for .Net applications. 

Please tell me, if there exist any function like that, in webkit browser.

Many thanks in advance.

Original comment by farooq.p...@gmail.com on 19 Nov 2011 at 3:48

GoogleCodeExporter commented 9 years ago
If I understood what you are trying to do, it is not implemented in the latest 
webkit. At some elements such as Input and other HTML elements there is a 
method called click() but as I have sawn in the latest webkit's source it is 
not implemented. Maybe it will be in the future but for now something like that 
is not possible. If I find any "hackish" method I will inform you.

Original comment by tsumalis96@gmail.com on 19 Nov 2011 at 10:27

GoogleCodeExporter commented 9 years ago
The feature that you want can also be done using JavaScript:

document.getElementById('id').click();

You can use that using <webkitbrowser>.StringByEvaluatingJavaScriptFromString 

Original comment by tsumalis96@gmail.com on 17 Apr 2012 at 4:01

GoogleCodeExporter commented 9 years ago
I dont understand, how solve this problem. 
e.g. I have own site, it is load in webkit browser. When I click 
button(picture) in html page, I need to write in com port, or make sound, or 
something else

Original comment by notfoo...@gmail.com on 4 Jul 2012 at 3:03

GoogleCodeExporter commented 9 years ago
OK I will reply you with an example. Let's say that the button you want has an 
ID attribute "myButton". So, in order to click it you can use the first way 
(for .NET 4) or the 2nd way (for any .NET Framework)

1st way:
<webkitbrowser>.GetScriptManager.EvaluateScript("document.getElementById('myButt
on').click();");

2nd way:
<webkitbrowser>.StringByEvaluatingJavaScriptFromString("document.getElementById(
'myButton').click();");

You can check the Id of the element via the inspector.

Original comment by tsumalis96@gmail.com on 4 Jul 2012 at 3:46

GoogleCodeExporter commented 9 years ago
Ok, but if I want to insert c# code on event:
SystemSounds.Beep.Play();

where I need to post it? 

Original comment by notfoo...@gmail.com on 4 Jul 2012 at 3:50

GoogleCodeExporter commented 9 years ago
Do you mean that you want to listen to a JavaScript event and run C# code? If 
so, then this capability is not yet implemented in OpenWebKitSharp (yet), but 
you can pass an object to JS via GetScriptManager.SetProperty("myObject", new 
MyObject());, inside the MyObject class put a method:

void Beep()
{
    SystemSounds.Beep.Play();
}

And instead of raising an event in JS, use myObject.Beep(); instead of the 
event or add a handler for that event in JS and use the above JS code.

Original comment by tsumalis96@gmail.com on 4 Jul 2012 at 4:38

GoogleCodeExporter commented 9 years ago
I have created a dynamic button in webkit browser. I need click even for that 
button.
How can I do it.

This is how I generate button:

mBrowser.DocumentText =
              "<html><head><script>" +
              "function test(message) { alert(message); }" +
              "</script></head><body><button " +
              "onclick=\"window.external.test('called from script code')\">" +
              "call client code from script code</button>" +
              "</body></html>";

Thanks in Advance.

Original comment by shivag...@gmail.com on 17 Aug 2012 at 7:49