Reputation: 406
Im trying to build an application where I use tabtip on every INPUT field in my webbrowser control. But I recently switched to WPF and in the old WinForms code I used
HtmlElement element = Browser.Document.GetElementFromPoint(e.ClientMousePosition)
In my new code i'm using a click event to determin the time on which im trying to open up tabtip but it only needs to happen when the clicked element is an INPUT field. My code:
public static void webBrowser1_LoadCompleted(object sender, NavigationEventArgs e, WebBrowser browser)
{
mshtml.HTMLDocument doc;
doc = (mshtml.HTMLDocument)browser.Document;
mshtml.HTMLDocumentEvents2_Event iEvent;
iEvent = (mshtml.HTMLDocumentEvents2_Event)doc;
iEvent.onclick += new mshtml.HTMLDocumentEvents2_onclickEventHandler(ClickEventHandler);
}
And this is where I want to check if the clicked element is an input:
private static bool ClickEventHandler(mshtml.IHTMLEventObj e)
{
MessageBox.Show("Item Clicked"); //if(HtmlElement == INPUT) like scenario here
return true;
}
I used this source but I have a hard time understanding their words since i'm trying to handle everything with xaml and c#.
Upvotes: 0
Views: 882
Reputation: 169218
Try this:
private static bool ClickEventHandler(mshtml.IHTMLEventObj e)
{
mshtml.IHTMLInputElement inputElement = e.srcElement as mshtml.IHTMLInputElement;
if (inputElement != null)
{
MessageBox.Show("<input> clicked");
}
return true;
}
Upvotes: 1