Creating a derived custom widget and initialization

Use this board for starting discussions, asking questions, and giving advice on Web programming for the IBM i platform (and predecessors.)
JacobPreston
New User
Posts: 10
Joined: Fri Apr 05, 2019 4:09 pm
First Name: Jacob
Last Name: Preston
Company Name: Preston Software
Contact:

Creating a derived custom widget and initialization

Post by JacobPreston »

I saw the example of creating a derived custom widget at http://www.profoundlogic.com/docs/displ ... ved+widget

Is it possible to create an initialization function to call when the derived widget is loaded?
For example, in the example for creating a custom widget from scratch at http://www.profoundlogic.com/docs/displ ... om+Scratch
The "field type" property of propertySetters is initialized to a function for initializing the widget.

Is there a way to do something like this for a custom derived widget? I tried setting the "field type" property to a function, but it does not appear to be firing when the widget is loaded.

For reference, this is what I tried just to see if I could get the "field type" event to fire when the widget is loaded. Will I have to create the widget from scratch in order to get this functionality?

Code: Select all

pui.toolbox.add({
  category: "Custom Widgets",
  widget: "select box",  
  text: "Custom List Box Test",
  icon: "/profoundui/proddata/images/icons/list_box.png",   
  // any property of a "select box" can be altered here
  defaults: {
    "select box height": "5",
    "width": "150px",
    "color": "#666666",
    "background color": "#FAE4AA",
    "choices": "Choice 1",
    "font family": "Sans-Serif",
    "font size": "12px"
  },
  // property setter functions
  propertySetters: {
 
    // this will fire when the field type property is set to "select box"
    "field type": function(parms) {
      if (parms.design) {

      }
      else 
      {
      	alert("This is a test to see if the field type property is firing for our custom derived widget.")                                                                                                                                    
      }
      }
    }, 
});
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Creating a derived custom widget and initialization

Post by Scott Klement »

A "derived" widget is one of the existing widgets added to the toolbox with different default properties.

Since you're not actually coding the widget, there's nowhere to put code that would run when the widget runs.

So, the answer is "no".
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests