MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / focus

Method focus

src/main/java/org/htmlunit/html/DomElement.java:1573–1589  ·  view source on GitHub ↗

Sets the focus on this element.

()

Source from the content-addressed store, hash-verified

1571 * Sets the focus on this element.
1572 */
1573 public void focus() {
1574 if (!(this instanceof SubmittableElement
1575 || this instanceof HtmlAnchor anchor && ATTRIBUTE_NOT_DEFINED != anchor.getHrefAttribute()
1576 || this instanceof HtmlArea area
1577 && (ATTRIBUTE_NOT_DEFINED != area.getHrefAttribute()
1578 || getPage().getWebClient().getBrowserVersion().hasFeature(JS_AREA_WITHOUT_HREF_FOCUSABLE))
1579 || this instanceof HtmlElement && ((HtmlElement) this).getTabIndex() != null)) {
1580 return;
1581 }
1582
1583 if (!isDisplayed() || isDisabledElementAndDisabled()) {
1584 return;
1585 }
1586
1587 final HtmlPage page = (HtmlPage) getPage();
1588 page.setFocusedElement(this);
1589 }
1590
1591 /**
1592 * Removes focus from this element.

Callers 1

clickMethod · 0.95

Calls 9

setFocusedElementMethod · 0.95
getWebClientMethod · 0.65
getPageMethod · 0.65
getHrefAttributeMethod · 0.45
hasFeatureMethod · 0.45
getBrowserVersionMethod · 0.45
getTabIndexMethod · 0.45
isDisplayedMethod · 0.45

Tested by

no test coverage detected