@@ -11,7 +11,7 @@ import {
1111 TYPES ,
1212} from "sprotty" ;
1313import { LabelAssignment , LabelType , LabelTypeRegistry , LabelTypeValue } from "./labelTypeRegistry" ;
14- import { DeleteLabelTypeAction , DeleteLabelTypeValueAction } from "./commands" ;
14+ import { AddLabelAssignmentAction , DeleteLabelTypeAction , DeleteLabelTypeValueAction } from "./commands" ;
1515import { LABEL_ASSIGNMENT_MIME_TYPE } from "./dropListener" ;
1616import { Action } from "sprotty-protocol" ;
1717import { snapPortsOfNode } from "../dfdElements/portSnapper" ;
@@ -261,6 +261,36 @@ export class LabelTypeEditorUI extends AbstractUIExtension implements KeyListene
261261 event . dataTransfer ?. setData ( LABEL_ASSIGNMENT_MIME_TYPE , assignmentJson ) ;
262262 } ;
263263
264+ valueInput . onclick = ( ) => {
265+ if ( valueInput . getAttribute ( "clicked" ) === "true" ) {
266+ return ;
267+ }
268+
269+ valueInput . setAttribute ( "clicked" , "true" ) ;
270+ setTimeout ( ( ) => {
271+ if ( valueInput . getAttribute ( "clicked" ) === "true" ) {
272+ this . actionDispatcher . dispatch (
273+ AddLabelAssignmentAction . create ( {
274+ labelTypeId : labelType . id ,
275+ labelTypeValueId : labelTypeValue . id ,
276+ } ) ,
277+ ) ;
278+ valueInput . removeAttribute ( "clicked" ) ;
279+ }
280+ } , 500 ) ;
281+ } ;
282+ valueInput . ondblclick = ( ) => {
283+ valueInput . removeAttribute ( "clicked" ) ;
284+ valueInput . focus ( ) ;
285+ } ;
286+ valueInput . onfocus = ( event ) => {
287+ // we check for the single click here, since this gets triggered before the ondblclick event
288+ if ( valueInput . getAttribute ( "clicked" ) !== "true" ) {
289+ event . preventDefault ( ) ;
290+ valueInput . blur ( ) ;
291+ }
292+ } ;
293+
264294 valueElement . appendChild ( valueInput ) ;
265295
266296 const deleteButton = document . createElement ( "button" ) ;
0 commit comments