[GH-ISSUE #73] Closing a Window programmatically #43

Closed
opened 2026-05-05 11:31:37 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @mischnic on GitHub (Mar 29, 2018).
Original GitHub issue: https://github.com/kusti8/proton-native/issues/73

The button "Show Preferences" correctly opens a window. The "Hide Preferences" button doesn't hide the window (but sets state.showPreferences to false). Furthermore, pressing "Show" after "Hide" opens a second child window because the old one didn't close.

class Notepad extends Component {
  state = { showPreferences: false};

  render() {
    return (
      <App>
        <Menu title="File">
          <Menu.Item type="Preferences" onClick={()=>this.setState({showPreferences: true})}/>
        </Menu>
        <Window title="Test" size={{ w: 500, h: 500 }} margined={true}>
          <Box>
            <Text>Hi!</Text>
            <Button onClick={()=>this.setState({showPreferences: true})}>Show Preferences</Button>
            <Button onClick={()=>this.setState({showPreferences: false})}>Hide Preferences</Button>
          </Box>
        </Window>
        {
          this.state.showPreferences &&
            <Window title="Preferences" size={{ w: 100, h: 100 }}
                    onClose={()=>this.setState({showPreferences: false})} lastWindow={false}>
            </Window>
        }
      </App>
    );
  }
}

After issuing "Show" - "Hide" - "Show":
bildschirmfoto 2018-03-29 um 23 38 11

Originally created by @mischnic on GitHub (Mar 29, 2018). Original GitHub issue: https://github.com/kusti8/proton-native/issues/73 The button "Show Preferences" correctly opens a window. The "Hide Preferences" button doesn't hide the window (but sets `state.showPreferences` to `false`). Furthermore, pressing "Show" after "Hide" opens a second child window because the old one didn't close. ```jsx class Notepad extends Component { state = { showPreferences: false}; render() { return ( <App> <Menu title="File"> <Menu.Item type="Preferences" onClick={()=>this.setState({showPreferences: true})}/> </Menu> <Window title="Test" size={{ w: 500, h: 500 }} margined={true}> <Box> <Text>Hi!</Text> <Button onClick={()=>this.setState({showPreferences: true})}>Show Preferences</Button> <Button onClick={()=>this.setState({showPreferences: false})}>Hide Preferences</Button> </Box> </Window> { this.state.showPreferences && <Window title="Preferences" size={{ w: 100, h: 100 }} onClose={()=>this.setState({showPreferences: false})} lastWindow={false}> </Window> } </App> ); } } ``` After issuing "Show" - "Hide" - "Show": ![bildschirmfoto 2018-03-29 um 23 38 11](https://user-images.githubusercontent.com/4586894/38114862-48f42c7e-33aa-11e8-9a5e-5d1c02e70341.png)
Author
Owner

@kusti8 commented on GitHub (Mar 30, 2018):

Currently when I remove a child, I don't have a method to close a Window.
d4d9760d97/src/components/DesktopComponent.js (L59-L67)
I'll add that. I'll make a release with fixes for a lot of issues and then get back to yoga.

<!-- gh-comment-id:377525571 --> @kusti8 commented on GitHub (Mar 30, 2018): Currently when I remove a child, I don't have a method to close a Window. https://github.com/kusti8/proton-native/blob/d4d9760d977908af1076e719f6624b4510d39c04/src/components/DesktopComponent.js#L59-L67 I'll add that. I'll make a release with fixes for a lot of issues and then get back to yoga.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/proton-native#43
No description provided.