This repository has been archived by the owner on Dec 22, 2023. It is now read-only.
How to center window on screen and fit to contents? #39
Answered
by
c-smile
GirkovArpa
asked this question in
Q&A
-
Is there a Sciter.JS equivalent? It's the only way I know how to center the window and also fit it to its contents, in TIScript: function self.ready() {
const w = self.intrinsicWidthMax();
const h = self.intrinsicHeight();
const (sw, sh) = view.screenBox(#frame, #dimension);
view.move((sw / 2) - (w / 2), (sh / 2) - (h / 2), w, h, true);
} |
Beta Was this translation helpful? Give feedback.
Answered by
c-smile
Feb 17, 2021
Replies: 1 comment 2 replies
-
Pretty much as it is: const [wmin,w] = document.state.contentWidths();
const h = document.state.contentHeight(w);
const [sw,sh] = Window.this.screenBox("frame", "dimension");
Window.this.move( (sw - w) / 2, (sh - h) / 2, w, h, true ); Relevant documentation: document/element.state and Window.this |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
GirkovArpa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pretty much as it is:
Relevant documentation: document/element.state and Window.this