vb net: How to handle a Gecko.DOM.GeckoInputElement click event

有些话、适合烂在心里 提交于 2019-12-11 18:25:43

问题


Is there a way to handle Gecko.DOM.GeckoInputElement click event? I have a submit button in a tag and I'd like to rise an event when I click it with the mouse. The website is open in a Gecko Browser.

I'm useing xulrunner-29.0b2.en-US.win32 and GeckoFx-Windows-29.0-0.1

My code is:

Friend WithEvents inputElement As Gecko.DOM.GeckoInputElement

Private Sub inputElement_click() Handles inputElement.Click

    MsgBox("a")
End Sub

but obviously "inputElement.Click" doesn't exists.


回答1:


The easiest way to do this is to add a DomClick Handler to the main control.

C#

browser.DomClick += click;

Then inside the handler look for your button and responded appropriately.

C#

click( object sender, DomEventArgs e )    
{

            if ( sender == null ) return;    
            if ( e == null ) return;    
            if ( e.Target == null ) return;    

            var element = e.Target.CastToGeckoElement();

            GeckoHtmlElement clicked = element as GeckoHtmlElement;    
            if ( clicked == null ) return;

            if ( clicked.TagName.ToLowerInvariant() == "input" && clicked.GetAttribute("type").ToLowerInvariant() == "submit" )

            {    
                e.Handled = true;

                MessageBox.Show("a");
        }


来源:https://stackoverflow.com/questions/25566626/vb-net-how-to-handle-a-gecko-dom-geckoinputelement-click-event

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!