I want that a double-click on an HTML table row selects the record.
I found the element to send a left-click, but I could not send a double-click. I checked that there was no mouse event control / attribute for the selection and I think it's because it was using a jquery / java function.
I cannot share the website. I know it can be done because someone has, but they are not sharing it.
The code that I believe is related to the function we need
/* double click on table row */
jQuery(tableId ).on('dblclick', ' tbody tr',function() {
if(isAutoNextEnabled!=null && isAutoNextEnabled=='Y'){
createAutoNextListNew(oTable, tableName, this);
}
window[functionName](this);
});
Since I cannot share the URL, I found an alternative https://unixpapa.com/js/testmouse-2.html
Here is a website that detect our clicks. It captures a single left-click, but does not capture a double-click.
I know there is a firevent option for the website provided, but the website where I need this function does not.
This works for a single-click, from the website (https://unixpapa.com/js/testmouse-2.html), it captures the left-click once:
set ta = objie.getElementsByTagName
for each x in ta
if x = [[our target ]]
x.click
end if
next x
It does not work when I double-click
for each x in ta
if x = [[our target ]]
x.doubleclick
end if
next x
or
for each x in ta
if x = [[our target ]]
x.doubleclick
end if
next x
The following shows adding htmlEvents (click and dblclick) and then firing them using your linked page
Option Explicit
Public Sub ClickTest()
Dim evtClick As Object, evtDblClick As Object, ie As InternetExplorer
Set ie = New InternetExplorer
With ie
.Visible = True
.Navigate2 "https://unixpapa.com/js/testmouse-2.html"
While .Busy Or .readyState <> 4: DoEvents: Wend
Set evtClick = .document.createEvent("HTMLEvents")
Set evtDblClick = .document.createEvent("HTMLEvents")
evtClick.initEvent "click", True, False
evtDblClick.initEvent "dblclick", True, False
With .document.querySelector("#link")
.dispatchEvent evtClick
.dispatchEvent evtDblClick
End With
With .document.querySelector("textarea")
Do
Loop While .innerText = vbNullString
Debug.Print .innerText
End With
End With
End Sub