How can I check if the element is focused?
This is my try:
I have prepared a function that checks if the object is focused:
_FFCmd('FFau3.isfocused=function isfocused(a){try{return (a === document.activeElement)}catch(e){return}}')
$oElm = _FFXPath("//*[@id='someId']")
_FFIsFocused($oElm)
Func _FFIsFocused($sElement = "")
Local $isFoc = _FFCmd("FFau3.isfocused(" & $sElement & ")")
Return $isFoc
EndFunc ;==>_FFIsFocused
It never trows TRUE. Seems like the object I'm sending is type XUL object.
Got help from Autoit forum from user Danp2!
The final code is:
_FFCmd('FFau3.isfocused=function isfocused(a){try{return (a === FFau3.WCD.activeElement)}catch(e){return}}')
$oElm = _FFXPath("//*[@id='someId']")
ConsoleWrite(_FFIsFocused($oElm))
Func _FFIsFocused($sElement = "")
Local $isFoc = _FFCmd("FFau3.isfocused(" & $sElement & ")")
Return $isFoc
EndFunc ;==>_FFIsFocused
The problem was with document.activeElement
that we couldn't access that way since we are doing it from inside the mozrepl.
FFau3.WCD.activeElement
is to be used instead.