I am implementing a custom browser based on Geckofx, i wanted to add a search engine where you can type any word and it search your document for coincidences, similar to Ctrl+F
Is there already a way to do this in geckofx?
EDIT: This works in GeckoFx 29, it does not work in GeckoFx 45
I know about one method that is not entirely satisfying - but maybe that will give you a starter info...
private void Find(bool backward)
{
string searchString = FindOnPageBox.Text;
var field = typeof(GWB).GetField("WebBrowser", BindingFlags.Instance | BindingFlags.NonPublic);
nsIWebBrowser nsIWebBrowser = (nsIWebBrowser)field.GetValue(TheBrowser);
var browserFind = Xpcom.QueryInterface<nsIWebBrowserFind>(nsIWebBrowser);
browserFind.SetSearchStringAttribute(searchString);
browserFind.SetMatchCaseAttribute(YourProgramName.Settings.CaseSensitiveSearch);
try
{
browserFind.SetWrapFindAttribute(true);
browserFind.SetFindBackwardsAttribute(backward);
browserFind.FindNext();
}
catch { }
}
And then invoke it on btn clicks...
private void findOnPage_Next_Button_Click(object sender, RoutedEventArgs e)
{
Find(false);
}
Have a look at this post: Find, HighLight, Scroll toText in Geckofx Web Page .
Written with VB.net 2010. It also works in Vb.net 2017.
Currently I am using in Windows 10 and the latest Geckofx60 and is working. Perfectly not always as I wrote it when using XuLRunner but the original code is their to modify to perfection if so desired.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.