Skip to main content
18-Opal
January 10, 2018
Question

Custom widget "Hello, World!" Issue

  • January 10, 2018
  • 2 replies
  • 5434 views

hi, i'm practice custom widget

TW.IDE.Widgets.helloWorld = function () {

  this.widgetIconUrl = function() {

      return  "../Common/extensions/HelloWorld_ExtensionPackage/ui/helloWorld/helloWorld.ide.png";

  };

 

  this.widgetProperties = function () {

    return {

      "name": "Hello, World!",

      "description": "An example widget.",

      "category": ['Common'],

      "properties": {

      "Salutation": {

          "baseType": "STRING",

          "defaultValue": "Hello, World!",

          "isBindingTarget": true

        },

       

        "TextSize":{

        "baseType":"NUMBER",

        "defaultValue":22,

        "isBindingTarget":true    

        }     

        }

    };

  };

 

  this.renderHtml = function () {

    return "<div class=\"widget-content widget-helloWorld\">" +

             "<span style=font-size: "+ this.getProperty("TextSize") +"px;>" + this.getProperty("Salutation") + "</span>" +

           "</div>";

  };

 

  this.afterSetProperty = function (name, value) {

    return true;

  };

  this.widgetEvents = function () {

      return {

          'Updated': {}

      }

  };

};

Hello, World We tried to construct a user widget that adjusts the font size by moving the slider using the example.(29 line)

However, the font size does not change.

The content inside is also unchanged.

How do I show the values that are bound in the widget?

2 replies

5-Regular Member
January 29, 2018

seonho Cha​: Please confirm if this issue is still open and need suggestions.

-Durgesh

CHASEONHO18-OpalAuthor
18-Opal
January 29, 2018

Hi, Durgesh Patel

I am trying to create reactive text.

We're still trying it now.

thank

1-Visitor
January 30, 2018

Hello, could you make it works in IDE (Composer) ?

1-Visitor
January 31, 2018

You can try with pure html to be sure that the css works.

Then in ThingWorx, on run time, can you see the css set in source code ?

CHASEONHO18-OpalAuthor
18-Opal
February 1, 2018

ide and rue time have the same css.

  1. .salutation { 
  2.   font-family: Impact, monospace; 
  3.   font-size: text-size // <- it defined properties in ide.js 
  4.   text-transform: uppercase;