Input Layout Behavior

Everything regarding the Power-Grid SDK can be asked and discussed here.

Input Layout Behavior

Postby rasczak » 27. May 2015, 04:08

Hey,

I'm trying to pre-populate an input layout. I'm calling setText("some string") on the layout object and it appears to get stored in the object because I can print the value of getText() but the value doesn't actually display on screen in the input box.

Any ideas?

Thanks in advance!
rasczak
 
Posts: 4
Joined: 24. Apr 2015, 22:55

Re: Input Layout Behavior

Postby Addihash » 27. May 2015, 09:46

My solution is to define a second layout which is the predefined text and make that invisible when pressed.

plugin.json:
Code: Select all
Name:"Input_skin",
Layouts:[
   {
      Name:"PreText",
      Type:"Text",
      Text:"type here",
      Left:"0",
      Top:"0",
      Width:"160",
      Height:"160",
      Color:"white",
      Font:"EuroB, 28"
      OnMousePress:"invisible",
      Visible:true,
      MouseMask:"none"
   },
   {
      Name:"Input_Layout",
      Type:"Input",
      Left:"0",
      Top:"0",
      Width:"160",
      Height:"160",
      Color:"white",
      Font:"EuroB, 28",
      Visible:false
   }
]


.qs file:
Code: Select all
function invisible(pxSkin)
{
   this.FindLayout("PreText").setVisible(false);
   this.FindLayout("Input_Layout").setVisible(true);
}
Addihash
Administrator
 
Posts: 232
Joined: 2. Feb 2015, 14:35

Re: Input Layout Behavior

Postby rasczak » 27. May 2015, 16:12

Thanks for the quick response. I had considered this approach before posting here and I don't think it will solve the problem. There are two problems here. One, if they want to modify the existing text, this solution would require them to retype all of the text as I cannot seem to pre-populate the input layout with the existing text. Second, I also cannot programmatically clear the input layout in the case that I want to reuse it for other labels that I am trying to set. The user has to manually delete all characters from the input layout before typing the new text.

A little background for what I'm trying to accomplish. I'm working on a grid for Star Citizen and I've created a section of the grid for user defined buttons that will execute actions that I've predefined in code. I was attempting to give the end user the ability to set an alias text for each button. I have everything working. I am able to reuse the input layout to set text for each button label and I'm able to assign user chosen predefined actions to the buttons. The only hitch is that I cannot pre-populate or clear the input layout for convenience sake.

Thanks again for your help
rasczak
 
Posts: 4
Joined: 24. Apr 2015, 22:55

Re: Input Layout Behavior

Postby Addihash » 27. May 2015, 16:26

For that purpose you might consaider using the config instead of a Input layout. Then the users could take your control, type in the names they want to and drag it on to an empty grid.

To do that your Controls[] would need to look like the following:
Code: Select all
Controls:[
   {
      Name:"MyControl",
      Skins:["MySkin"],
      Config:{
         Description:"This Is a description.",
         Options:[
                      {
               Type:"Text",
               Name:"TextInput",
               Title:"Title of the Input field :",
               Value:"predefined text",
            },
            {
               Name:"DropDown",
               Title:"Title Of the Drop Down",
               Type:"Drop",
               Items:["Preselected Value", "value1", value2", "value3"],
               Params:"verbatim"
            }
         ],
      },
      Width:4,
      Height:6
   }      
]


Take a look at the Sample2 of the SDK to see more examples

Edit: you don't need the dropdown, but it was in there and I thought you might want to see it too :D
Addihash
Administrator
 
Posts: 232
Joined: 2. Feb 2015, 14:35


Return to Power-Grid SDK

Who is online

Users browsing this forum: No registered users and 1 guest