In this example, we demonstrate the communication process between the Show UI and the Template UI to dynamically update the graphical user interface based on user input.
By storing the user's selection in session storage and listening for changes, the Template UI can promptly reflect the user's choices, providing a responsive and interactive user experience.
Show ezUI:
1 2 3 4 5 6 7 8 9101112131415161718192021
letdrag=false;constrealSize=200;functiononPointerDown(e){drag=true;area.setPointerCapture(e.pointerId);}// Event listener for the highlight button click eventbtnHighlight.onClick=()=>{// Store the selected value from the dropdown in session storage under the key 'highlight'sessionStorage.setItem('highlight',dropdown.value);};// Initial ReadfunctionreadData(){updatePosition('x',vtxPosition.value.x);updatePosition('y',vtxPosition.value.y);}readData();
letdrag=false;constrealSize=200;functiononPointerDown(e){drag=true;area.setPointerCapture(e.pointerId);}// Function to set the highlight based on the provided valuefunctiononSetHighlight(value:string){lethighlight=-1;// Initialize highlight variable to -1// Determine the highlight value based on the inputswitch(value){case'Option 1':highlight=1;break;case'Option 2':highlight=2;break;case'Option 3':highlight=3;break;}/* Loop through the options and update the border color of the corresponding buttons*/for(leti=1;i<=3;i++){constbtn=findElement(`btnOption${i}`);// Find the button elementif(btn)btn.style.borderColor=(i===highlight?'red':undefined);/* Set border color to red if highlighted, otherwise undefined */}}// Event listener for changes in session storage 'highlight' keysessionStorage.on('highlight',e=>onSetHighlight(e.value));// Initial ReadfunctionreadData(){updatePosition('x',vtxPosition.value.x);updatePosition('y',vtxPosition.value.y);}readData();