Thread: How to change size of a window
-
March 5th, 2023, 12:14 #1
-
March 5th, 2023, 19:08 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,557
You can not change the size of an embedded window, only top-level windows.
For windowlists, the width of the children will match the windowlist width; and the height will be the height of all the controls in the embedded window.
For subwindows, the width and the height of the controls in the embedded window determine the width and height.
If you need to adjust width/height of embedded window dynamically, you'll probably need to define controls that you can show/hide to increase/decrease the height (i.e. spacers/footers/etc)
Regards,
JPG
-
March 5th, 2023, 23:55 #3
-
March 6th, 2023, 00:59 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,557
Are you trying to override an existing window? Is the window tied to a panel that already has anchors and fixed sizes?
It would help to know more about what you are trying to do, and to which windows.
Regards,
JPG
-
March 6th, 2023, 17:42 #5
This is my code. I do not show you header code, I think it's superfluous
Code:<windowclass name="my_class"> <frame>recordsheet</frame> <placement> <size width="450" height="220" /> </placement> <minimize>minimized_reference</minimize> <tooltip field="name" /> <script file="campaign/records/scripts/record_generic.lua" /> <sharable /> <sheetdata> <sub_record_header name="header"> <class>my_header</class> </sub_record_header> <frame_record_content name="contentframe" /> <subwindow_record name="main"> <class>ref_my_main</class> <activate /> <fastinit/> </subwindow_record> <scrollbar_record> <target>main</target> </scrollbar_record> <resize_recordsheet /> <close_recordsheet /> </sheetdata> </windowclass> <windowclass name="ref_my_main"> <margins control="0,0,0,2" /> <script file="campaign/classes/scripts/class_my_main.lua" /> <sheetdata> <genericcontrol name="controlwheel"> <anchored> <top offset="0" /> <left offset="0" /> <right offset="-15" /> <bottom offset="-5" /> </anchored> <script file="common/scripts/mycontrol.lua"/> </genericcontrol> </sheetdata> </windowclass>
Controls created can span 3, 5, or 10 rows. I would therefore like the window to be sized adequately and I
would not want it to be resized by those who are using it.
The genericcontrol is placed on top of the others controls using bringToFront() and it's purpouse is to track
the onWheel event. This event changes some value in all controls created, not the number of them.
-
March 6th, 2023, 18:54 #6
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,557
If you look at some of the existing window classes for record types in the D&D rulesets (such as "item" or "npc"); you'll see that they use a bunch of *_column controls that automatically stack on top of each other. Then, within the script code, you just call the update when the read only state changes to "update" which auto-hides the field if empty. Then, the content of the window automatically sizes to the correct size.
Remember that the subwindow control already supports scrolling automatically if the vertical size of the child window exceeds the height of the subwindow. That's why there is a scrollbar control in that window class. It will only appear if the child size is greater than the subwindow size.
You should not be placing any controls over the top, as it will interfere with all mouse interactions for any controls below it.
Regards,
JPG
-
March 6th, 2023, 19:29 #7
Controls a placed in specific places and the user doesn't need to directly interact with them.
They show information. So *_column are not what I need. When the wheel is used, all controls
must show different information, even if the wheel is used on the window, but not on a specific
control. As far as I can see the windowclass doesn't implement onWheel event, that's why I need
a control over all the others.
But this is not my problem. My problem is that I load data, create X information on the window
and I need the window resize in the way I need (450x220; 750x440; etc.).
Using parentcontrol.window.setSize(x,y) does not give any error or warning, but the window is
not resized and I don't know why.
-
March 6th, 2023, 20:16 #8
The bold XML above makes your window static.
Refer to the windowclass reference here: https://fantasygroundsunity.atlassia...44/windowclass
See the <sizelimits> section - and also <dynamic />Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
March 7th, 2023, 08:51 #9
I tried in this way and discovered something
Code:<windowclass name="my_ckass"> <frame>recordsheet</frame> <sizelimits> <dynamic /> </sizelimits> ... </windowclass>
Code:Debug.console(parentcontrol.window.getSize()); parentcontrol.window.setSize(450, 800); Debug.console(parentcontrol.window.getSize());
#200|#200
#450|#800
The window has resized. Now if I change code in
Code:Debug.console(parentcontrol.window.getSize()); parentcontrol.window.setSize(800, 450); Debug.console(parentcontrol.window.getSize());
#200|#200
#800|#450
But the window remains in his previous version: 450,800
It changes only if I remove windowstate.xml
-
March 7th, 2023, 19:51 #10
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,557
If you are trying to change the position of the window in an onInit call; those occur before the windowstate saved placements are called. You might be able to get around that my changing the size in onFirstLayout.
However, I still think that you are perhaps overcomplicating the need. Just have all the correct fields in the content area, and let the content area scroll. There's usually very little need to force a resize based on content, since the content already scrolls.
Regards,
JPG
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks