Skip to content

Nested window support (Modals or Dialogs) #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mrxdst opened this issue Jan 1, 2020 · 3 comments · Fixed by #344
Closed

Nested window support (Modals or Dialogs) #108

mrxdst opened this issue Jan 1, 2020 · 3 comments · Fixed by #344
Labels
enhancement New feature or request

Comments

@mrxdst
Copy link

mrxdst commented Jan 1, 2020

Describe the bug
Opening and closing new windows doesn't work properly when nested inside another window

To Reproduce
Run the following example code

import React, { useState } from "react";
import { Renderer, Window, View, Button, Text } from "@nodegui/react-nodegui";

function MainWindow() {
  const [open1, setOpen1] = useState(false);
  const [open2, setOpen2] = useState(false);
  const [open3, setOpen3] = useState(false);

  return (
    <>
      <Window windowTitle="Main window">
        <View>
          <Button text="Nested in view"   on={{clicked: () => setOpen1(!open1)}}/>
          <Button text="Nested in window" on={{clicked: () => setOpen2(!open2)}}/>
          <Button text="Not nested"       on={{clicked: () => setOpen3(!open3)}}/>
          {open1 && <Dialog text="Nested in view"/>}{/* Does not work */}
        </View>
        {open2 && <Dialog text="Nested in window"/>}{/* Partialy working */}
      </Window>
      {open3 && <Dialog text="Not nested"/>}{/* This works */}
    </>
  );
}

function Dialog({text}: {text: string}) {
  return (
    <Window windowTitle={text}>
      <View>
        <Text>{text}</Text>
      </View>
    </Window>
  )
}

Renderer.render(<MainWindow />);

Expected behavior
That windows can be open and closed no matter where they are placed in the react tree.

Desktop (please complete the following information):

  • OS: Linux
  • NodeGUI version: 0.12.1
  • React NodeGUI version: 0.4.0
  • OS Version: Arch Linux
@a7ul
Copy link
Collaborator

a7ul commented Jan 9, 2020

Hi @mrxdst

A QMainWindow (Window) cannot be a child of another QMainWindow
Thats why you can only have multiple top level windows and not nested windows.

What you are looking for is support for QDialog or modals. That has not yet been exported from NodeGui to React NodeGui.

If you want the QDialog behaviour immediately, maybe you can help export it out in React NodeGui ?

Otherwise I can do it when time permits.

@a7ul a7ul changed the title Nested window support Nested window support (Modals or Dialogs) Jan 9, 2020
@a7ul a7ul added the enhancement New feature or request label Jan 9, 2020
@mrxdst
Copy link
Author

mrxdst commented Jan 9, 2020

@master-atul

Ok, I understand. I do not need this immediately.

@a7ul a7ul closed this as completed Jan 19, 2020
@a7ul a7ul reopened this Jan 19, 2020
@mako87
Copy link

mako87 commented Mar 10, 2020

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants