-
October 15th, 2020, 04:41 #1
- Join Date
- Jan 2020
- Posts
- 222
Resize a window programmatically if it's not a <dynamic /> window?
I have a window that's not <dynamic /> and when I try to setSize() on it it won't work.
If I change it to a <dynamic /> window, the setSize() works most of the time, but many times I get sizes that don't make sense.
Thoughts?
-
October 15th, 2020, 06:53 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,558
Top-level windows will attempt to resize to fit the controls within the windows. This might be what you are seeing.
JPG
-
October 15th, 2020, 15:19 #3
- Join Date
- Jan 2020
- Posts
- 222
Seems like it.
Does a window need <dynamic / > to resize it programmatically?Last edited by zuilin; October 15th, 2020 at 16:03.
-
October 15th, 2020, 16:13 #4
- Join Date
- Jan 2020
- Posts
- 222
Here's an even better question....
Is there any method that fires after it's done its automatic resizing as you mention above?
Right now I'm doing my .setSize() in .onInit() for the window, but perhaps there some other callback that fires well-after .onInit() and after the window is completely done drawing itself where I could put my own resize in instead.
I'd really like to be able to confidently set the size of the window immediately before the user starts interacting with it.
Thoughts?Last edited by zuilin; October 15th, 2020 at 16:13. Reason: spelling
-
October 15th, 2020, 17:02 #5
- Join Date
- Jan 2020
- Posts
- 222
FYI I tried onFirstLayout() but that fires before onInit(). I do my resizing in onInit() and it seems that it should work if the built-in layout is done before onFirstLayout(). It doesn't seem to have predictable behaviour from my hours of testing
-
October 15th, 2020, 17:56 #6
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,558
In normal operation, the onInit event fires for each control and then the window instance; then the layout is performed which triggers onFirstLayout events. If you inject calls into the onInit events that trigger a layout, the onFirstLayout could potentially trigger before onInit.
Try adding simple Debug.chat output in those events without any other script code, so that you see the default flow without having your code injecting alternate code paths.
Regards,
JPG
-
October 15th, 2020, 18:12 #7
- Join Date
- Jan 2020
- Posts
- 222
-
October 15th, 2020, 22:21 #8
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,558
Taking a quick look at the code. Top-level windows are laid out before onInit is called; but embedded windows (containers/lists) are laid out after onInit is called.
Regards,
JPG
-
October 15th, 2020, 22:32 #9
- Join Date
- Jan 2020
- Posts
- 222
-
October 16th, 2020, 01:25 #10
- Join Date
- Jan 2020
- Posts
- 222
OK, so lots of testing later...
Pre: I have a formattedtextcontrol in the middle of my window and it's anchored (effectively) to the edges of the window (more or less, indirectly, anyway). Check.
1. When I don't programmatically put any text in the formattedtextcontrol, the window always stays the same size when it's generated. Check. ****** EDIT: STRIKE THIS. NOW IT'S DOING IT WITH NO TEXT. ******
2. When I DO programmatically put any text in the formattedtextcontrol, it often changes size. Check. Not what I want.
3. I've run scripts on everything I can think of for the window itself and within methods of the formattedtextcontrol...
The resizing happens well-AFTER any of these fire in the formattextextcontrol:
onInit
onFirstLayout
onValueChanged -- This one surprises me, because it seems like it's the putting text into the formattedtextcontrol that causes the resize.
I've even tried, immediately following setting the text in the formattedtextcontrol, to send the window a notifyUpdate and THEN do the resize...still, to no avail.
I'm completely at a loss. Somewhere in the UI drawing, it's changing the size of the window and I don't seem to be able to have access to the moment in time that it's doing it. I guess I'm stuck with a boring, static window. Sigh.Last edited by zuilin; October 16th, 2020 at 01:32.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks