简体   繁体   中英

Error when implementing onMarkupSelectedBinded this.markup event is null MarkupsCore

How can I use the onMarkupSelected event in MarkupsCore, and when implementing the onMarkupSelectedBinded event Markup.js returns an error stating that this.markup is null.

var _markup;
ExtesionsOpenMarkup.prototype.createUi = function (event) {
    _viewer = this.viewer;
    setViewableData()
    _btnMarkup = new Autodesk.Viewing.UI.Button('btn-markup');
    _btnMarkup.onClick = function (e) {
        _markup = _viewer.getExtension("Autodesk.Viewing.MarkupsCore");
        createToolBarMarkup();
        _markup.onMarkupSelectedBinded = function () {
            alert('test')
        }
    };    
}

The Markup extension exposes an EventTarget interface you can use to subscribe to its events. Try the following snippet of code in your button click handler:

const markupExtension = _viewer.getExtension("Autodesk.Viewing.MarkupsCore");
const namespace = Autodesk.Viewing.Extensions.Markups.Core;
markupExtension.addEventListener(namespace.EVENT_MARKUP_SELECTED, function(ev) {
    console.log(ev.markup);
    alert('Markup selected!');
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM