Programatic UI Changes

Posted on
Wed Jul 18, 2018 8:46 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Programatic UI Changes

I would really love to be able to change certain "fixed" UI components programmatically, like labels and button names. It would alleviate a lot of extra checkboxes that I have to use to hide or show certain things if I could just simply modify the text of a label or button on the fly. I understand a lot of this likely has to do with rendering the window initially based on the fields and widths but since there is a proliferation of feature requests lately (many from me) then I thought I would toss this in there.

And, yea, it's probably already on the list :roll: .

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Wed Jul 18, 2018 9:29 am
mat offline
Posts: 753
Joined: Nov 25, 2010
Location: Cambridgeshire - UK

Re: Programatic UI Changes

More resources, but how about using a variable?

Late 2018 mini 10.14

Posted on
Wed Jul 18, 2018 9:31 am
jay (support) offline
Site Admin
User avatar
Posts: 15539
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Programatic UI Changes

Colorado4Wheeler wrote:
I would really love to be able to change certain "fixed" UI components programmatically, like labels and button names. It would alleviate a lot of extra checkboxes that I have to use to hide or show certain things if I could just simply modify the text of a label or button on the fly. I understand a lot of this likely has to do with rendering the window initially based on the fields and widths but since there is a proliferation of feature requests lately (many from me) then I thought I would toss this in there.

And, yea, it's probably already on the list :roll: .


What UI components exactly?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jul 18, 2018 10:04 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Programatic UI Changes

jay (support) wrote:
What UI components exactly?


I would really love to be able to change certain "fixed" UI components programmatically, like labels and button names.


This is for the plugin API. Unless I've been on crack all this time and can change labels and buttons on the fly in my plugins :shock:.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Wed Jul 18, 2018 10:25 am
DaveL17 offline
User avatar
Posts: 4886
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Programatic UI Changes

Not sure that this is completely on target, but here goes. Couldn't you call getDeviceConfigUiXml() (as an example), make changes to the XML as needed and then pass it back?

I did this in the latest versions of the GhostXML plugin to address a situation where a user could set a config value that's not in the "standard" set. If the value is not standard, the plugin returns a "Custom" option. The code might be a bit literal at this point, but it seems to work well.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Jul 18, 2018 10:26 am
jay (support) offline
Site Admin
User avatar
Posts: 15539
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Programatic UI Changes

Ok, that's the scope (wasn't clear) - so what labels? You can change the button title on a menu item dialog by adding:

Code: Select all
<ButtonTitle>Send</ButtonTitle>


to the MenuItem section:

Code: Select all
   <MenuItem id="menu3">
      <Name>Override Server Version</Name>
      <CallbackMethod>overrideServerVersion</CallbackMethod>
      <ConfigUI>
         <Field id="versionNumber" type="textfield">
            <Label>Version number:</Label>
         </Field>
      </ConfigUI>
      <ButtonTitle>Send</ButtonTitle>
   </MenuItem>

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jul 18, 2018 10:28 am
DaveL17 offline
User avatar
Posts: 4886
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Programatic UI Changes

So I see Jay and I have a different spin on the question. :D

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Jul 18, 2018 10:32 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Programatic UI Changes

Code: Select all
<Field type="button" id="add" >
   <Label> </Label>
   <Title>Save Device </Title>
   <CallbackMethod>serverButtonAddDeviceOrAction</CallbackMethod>
</Field>


Then have something like:

Code: Select all
valuesDict['add'].title = 'Delete Device'


Or

Code: Select all
<Field type="label" id="mylabel" >
   <Label>Here is text I want to show on the UI form</Label>
</Field>


And change it with:

Code: Select all
valuesDict['mylabel'] = 'Hello world'


DaveL17 wrote:
Couldn't you call getDeviceConfigUiXml()


Probably (does that reload in real time or next time device UI is opened?) but that seems like a lot more coding to get that done that to change the valuesDict that already shows the labels as objects.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Wed Jul 18, 2018 1:12 pm
mat offline
Posts: 753
Joined: Nov 25, 2010
Location: Cambridgeshire - UK

Re: Programatic UI Changes

doh! i was miles off, thought you meant control pages - must get some sleep!!!

Late 2018 mini 10.14

Posted on
Wed Jul 18, 2018 3:17 pm
jay (support) offline
Site Admin
User avatar
Posts: 15539
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Programatic UI Changes

Once a dialog is running, the only thing that is bound to live data are the values displayed in the fields, so there's no current way to change those while the dialog is running. This isn't likely to change in the foreseeable future given the pervasive code changes that would be required.

You can make the dialogs more dynamic at load time however by using the above mentioned hook method.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jul 18, 2018 3:50 pm
matt (support) offline
Site Admin
User avatar
Posts: 19175
Joined: Jan 27, 2003
Location: Texas

Re: Programatic UI Changes

I've needed this type of capability before as well a few times. I ended up just creating multiple controls and setting the visibility of the controls dynamically so that only the "correct" one is showing (sounds like you do the same already). But that can get cumbersome quickly if there are lots of permutations, of course.. So +1 for me on sympathy for the problem, but as Jay said it isn't likely to be implemented anytime soon given the nature of the changes that would be involved.

Image

Posted on
Wed Jul 18, 2018 3:59 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Programatic UI Changes

jay (support) wrote:
You can make the dialogs more dynamic at load time however by using the above mentioned hook method.

That's what I do if I need to manipulate before the form is loaded, just wanting to drop this request in the hat so I don't have to :).

matt (support) wrote:
sounds like you do the same already

Yes sir I do.

matt (support) wrote:
But that can get cumbersome quickly if there are lots of permutations, of course.

I'm actually writing a method to make my life much easier in that regard. I'm playing with it under the new 1.1 of HKB and it's actually pretty slick! Of course there are a lot of moving parts but it works much better than using a thousand checkboxes to get the job done.

Well, at least everyone is clear on the request and why I put it in "the box". ;)

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests