Forum Archive

User Data Attribute for ui elements

Phuket2

@omz, I am sorry to sound like a broken record on this Topic. But it would be so handy if ui elements had a user_data attribute. Or whatever you want to call it. I am not sure how difficult this or if it would break anything. I know this can be sort of achieved with custom classes etc. but sometimes, it would be nice just to poke a reference to some data or whatever directly into the ui.item itself. It would be nice if all elements from ui.View down had this attribute. I think it's far more useful than it sounds on the surface.

JonB

The beta version like 3 or 4 versions ago added this feature just for you! Check release notes... now you can add custom attributes to any ui.View instances (including ui.Buttons, etc)

omz

This is my favorite kind of feature request. ;)

ccc

How do you get back the release notes? I knew @omz had done it but did not know how to get back the release note to prove it to myself.

Webmaster4o

Aren't all the release notes in Beta Release Notes.md

JonB

Build 160020

[...]

  • ui.View now supports setting arbitrary attributes, so you don't have to subclass in order to attach some auxiliary data to a view (or any subclass of ui.View). Note that this might hide bugs/typos in your code because something like my_view.fame = ... (instead of my_view.frame) no longer throws an exception (but this is consistent with the way most objects in Python work).

  • The UI editor now supports setting custom attributes for views. You can use this to attach arbitrary data to a view or to set built-in attributes that aren't supported directly in the UI editor's inspector (e.g. ui.TextField.keyboard_type).

techteej

@Webmaster4o Yep. All there.

Phuket2

Wow, that's fantastic. It. Must of been done before I started using 1.6. I have been reading the release notes, but not all the history. I should have. But this is great....
Thanks guys...