Skip to content
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
Discussion options

You must be logged in to vote

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

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@GirkovArpa
Comment options

@liudonghua123
Comment options

Answer selected by GirkovArpa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #38 on February 17, 2021 13:56.