1"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([["10986"],{72340:function(n,e,o){o.r(e),o.d(e,{metadata:()=>t,default:()=>p,frontMatter:()=>a,contentTitle:()=>c,toc:()=>r,assets:()=>l});var t=JSON.parse('{"id":"api/tools/namespaces/Types/type-aliases/ToolAction","title":"Type Alias: ToolAction","description":"ToolAction: object","source":"@site/docs/api/tools/namespaces/Types/type-aliases/ToolAction.md","sourceDirName":"api/tools/namespaces/Types/type-aliases","slug":"/api/tools/namespaces/Types/type-aliases/ToolAction","permalink":"/docs/api/tools/namespaces/Types/type-aliases/ToolAction","draft":false,"unlisted":false,"editUrl":"https://github.com/cornerstonejs/cornerstone3D/edit/main/packages/docs/docs/api/tools/namespaces/Types/type-aliases/ToolAction.md","tags":[],"version":"current","frontMatter":{},"sidebar":"typedocSidebar22","previous":{"title":"Type Alias: TextBoxHandle","permalink":"/docs/api/tools/namespaces/Types/type-aliases/TextBoxHandle"},"next":{"title":"Type Alias: ToolConfiguration","permalink":"/docs/api/tools/namespaces/Types/type-aliases/ToolConfiguration"}}'),s=o(31085),i=o(92600);let a={},c="Type Alias: ToolAction",l={},r=[{value:"Type declaration",id:"type-declaration",level:2},{value:"bindings",id:"bindings",level:3},{value:"method",id:"method",level:3},{value:"Defined in",id:"defined-in",level:2}];function d(n){let e={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",p:"p",pre:"pre",strong:"strong",...(0,i.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"type-alias-toolaction",children:"Type Alias: ToolAction"})}),"\n",(0,s.jsxs)(e.blockquote,{children:["\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.strong,{children:"ToolAction"}),": ",(0,s.jsx)(e.code,{children:"object"})]}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"An action that may be defined at the tool configuration level"}),"\n",(0,s.jsx)(e.p,{children:"Annotations can have actions that run a specific task (ex: showing a dropdown\ncontaining a list of all predefined zoom levels - advanced magnifier glass).\nEach action must have at least one binding option (mouse button + [modifier(s)])\nand a action runs if and only if no other tool is using that same binding options\nto draw an annotation because action has lower priority."}),"\n",(0,s.jsx)(e.p,{children:"Actions are defined in the following way in a annotation tool constructor:"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{children:"class MyAnnotationTool extends AnnotationTool {\n constructor(\n toolProps: PublicToolProps = {},\n defaultToolProps: ToolProps = {\n configuration: {\n actions: [\n {\n method: 'myAction',\n bindings: [\n {\n mouseButton: MouseBindings.Secondary,\n modifierKey: KeyboardBindings.Shift,\n }\n ]\n }\n ]\n }\n }\n ) {\n super(toolProps, defaultToolProps);\n }\n\n public myAction(evt: EventTypes.InteractionEventType, annotation: MyAnnotation) {\n // action code\n }\n}\n"})}),"\n",(0,s.jsxs)(e.p,{children:['The "method" property may be a string or a javascript function. In case it is\na string a function with same name must exists in the tool class. In both ways\n(string or function) the function is called in the tool\'s context (',(0,s.jsx)(e.code,{children:"this"}),")"]}),"\n",(0,s.jsx)(e.h2,{id:"type-declaration",children:"Type declaration"}),"\n",(0,s.jsx)(e.h3,{id:"bindings",children:"bindings"}),"\n",(0,s.jsxs)(e.blockquote,{children:["\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.strong,{children:"bindings"}),": ",(0,s.jsx)(e.a,{href:"/docs/api/tools/namespaces/Types/type-aliases/SetToolBindingsType",children:(0,s.jsx)(e.code,{children:"SetToolBindingsType"})}),"[]"]}),"\n"]}),"\n",(0,s.jsx)(e.h3,{id:"method",children:"method"}),"\n",(0,s.jsxs)(e.blockquote,{children:["\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.strong,{children:"method"}),": ",(0,s.jsx)(e.code,{children:"string"})," | (",(0,s.jsx)(e.code,{children:"evt"}),", ",(0,s.jsx)(e.code,{children:"annotation"}),") => ",(0,s.jsx)(e.code,{children:"void"})]}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"defined-in",children:"Defined in"}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.a,{href:"https://github.com/cornerstonejs/cornerstone3D/blob/4d2556f1c5ddd965b164966b70c9292531653c90/packages/tools/src/types/ToolAction.ts#L47",children:"tools/src/types/ToolAction.ts:47"})})]})}function p(n={}){let{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(d,{...n})}):d(n)}},92600:function(n,e,o){o.d(e,{R:()=>a,x:()=>c});var t=o(14041);let s={},i=t.createContext(s);function a(n){let e=t.useContext(i);return t.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:a(n.components),t.createElement(i.Provider,{value:e},n.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.