java element类怎么用_Java JsElement类代码示例

import elemental.js.dom.JsElement; //导入依赖的package包/类

private void setupShowAdditionalInfo(final CMHintResultsOverlay data,

final AdditionalInfoCallback additionalInfoCallback) {

if (additionalInfoCallback != null) {

final CodeMirrorOverlay codeMirror = editorWidget.getCodeMirror();

final Element bodyElement = Elements.getBody();

codeMirror.on(data, EventTypes.COMPLETION_SELECT, new EventHandlers.EventHandlerMixedParameters() {

@Override

public void onEvent(final JsArrayMixed param) {

// param 0 -> completion object (string or object)

final CMCompletionObjectOverlay completionObject = param.getObject(0);

// param 1 -> DOM node in the menu

final JsElement itemElement = param.getObject(1);

final ClientRect itemRect = itemElement.getBoundingClientRect();

Element popup = itemElement;

while (popup.getParentElement() != null && ! popup.getParentElement().equals(bodyElement)) {

popup = popup.getParentElement();

}

final ClientRect popupRect = popup.getBoundingClientRect();

final float pixelX = Math.max(itemRect.getRight(), popupRect.getRight());

final float pixelY = itemRect.getTop();

final Element info = getAdditionalInfo(completionObject);

// there can be only one

// remove any other body child with the additional info marker

removeStaleInfoPopups(ADDITIONAL_INFO_MARKER);

// Don't show anything if there is no additional info

if (info == null) {

return;

}

final Element infoDisplayElement = additionalInfoCallback.onAdditionalInfoNeeded(pixelX, pixelY, info);

// set the additional info marker on the popup element

infoDisplayElement.getClassList().add(ADDITIONAL_INFO_MARKER);

}

});

// close the additional info along with the completion popup

codeMirror.on(data, EventTypes.COMPLETION_CLOSE, new EventHandlers.EventHandlerNoParameters() {

@Override

public void onEvent() {

delayedRemoveStaleInfoPopups(ADDITIONAL_INFO_MARKER);

}

});

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值