-
September 1st, 2022, 23:45 #1
- Join Date
- Aug 2020
- Posts
- 94
Overriding WindowClass instance attributes from LUA
Hi,
is it possible to change some attributes (e.g. title) of the Window instance from within LUA? Since the change should be dynamic, I do not want to create separate new window templates.
Here is an example of what I am trying to do:
Code:<windowclass name="some_window_class" merge="join"> <script> function onInit() Debug.chat(" onInit() called"); ------ I would like to change the title of this window instance (depending on some logic) end </script> </windowclass>
-
September 2nd, 2022, 00:00 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,557
Well, first, you need to call any base window onInit call. Then, it depends on the window class and templates/names being used for that ruleset.
For most windows in the 5E ruleset (but not all), it could be as simple as:
Code:function onInit() if super and super.onInit then super.onInit(); end title.setValue("My Custom Window Title"); end
JPG
-
September 2nd, 2022, 01:28 #3
- Join Date
- Aug 2020
- Posts
- 94
Amazing, this works perfectly.
However now I am stuck trying to access subwindow elements of the current window.
EDIT: Figured it out myself: elements of subwindow can be accessed via in the case below "subwin.subwindow.element_name"
Code:<windowclass name="main_window_class"> <sheetdata> <subwindow_record name="subwin"> <class>subwindow_class</class> <activate /> <fastinit /> </subwindow_record> </sheetdata> </windowclass> <windowclass name="subwindow_class"> <sheetdata> <header_column name="element_name"> <static textres="text_to_be_changed" /> <center /> </header_column> </sheetdata> </windowclass>
Last edited by xelab; September 2nd, 2022 at 01:48.
-
September 2nd, 2022, 03:22 #4
- Join Date
- May 2016
- Posts
- 521
This may help with a lot of your recent questions...
https://forge.fantasygrounds.com/shop/items/358/view
Jason
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks