CurriculumAssociates / createjs-accessibility

Helping to make a Createjs canvas accessible

Home Page:https://curriculumassociates.github.io/createjs-accessibility

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to un-register elements?

banjahman opened this issue · comments

I was wondering if there's the ability to un-register elements after they've been created? My canvas object will hide a button under certain situations and I'm still able to tab to the element after it's been hidden within the canvas.

Nevermind, I did some digging in the source and found a way to accomplish what I wanted.

For anyone looking on how to do this, see the following code snippet.

const root = new createjs.Container();
AccessibilityModule.register( {
  displayObject: root,
  role: AccessibilityModule.ROLES.NONE
} );

const element = new createjs.Container();
AccessibilityModule.register( {
  displayObject: element,
  role: AccessibilityModule.ROLES.BUTTON,
  parent: this.root
} );

// de-register the element
const r = root as any;
r.accessible.removeChild( element );