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

Toggle-window behavior question #59

Closed
igorepst opened this issue Aug 23, 2023 · 6 comments
Closed

Toggle-window behavior question #59

igorepst opened this issue Aug 23, 2023 · 6 comments

Comments

@igorepst
Copy link

Hi @Aylur ,
Given the following config:

import {
    Window
} from 'resource:///com/github/Aylur/ags/widget.js';

const InfoPopup = () => Window({
    name: 'InfoPopup',
    style: 'background-color: red',
    visible: false,
})

export default {
    windows: [
	InfoPopup(),
    ],
};

if I run ags --toggle-window 'InfoPopup', the window is shown after the command run the third time only and not the first. If the window has visible: true property, the command works obviously the second time, but it means the window should be shown immediately at the start of ags, no?
This is a reduced example, the goal is to bind onClicked: () => App.toggleWindow('InfoPopup') to a button.
Thank you in advance

@Aylur
Copy link
Owner

Aylur commented Aug 23, 2023

That's weird, seems like when there are no child on a Window it misbehaves. If you add any child to it, it works as expected

@Aylur
Copy link
Owner

Aylur commented Aug 23, 2023

I can't figure out what could cause this. It never occurred to me, every time I tested a Window I always added a Label('test') as a child

@igorepst
Copy link
Author

Huh, indeed. I would like to add that originally I used an empty box as a child, but this started working as soon as I added a label to the box.
Closing, as there is no real issue there. Probably this may be documented somehow.
Thank you

@end-4
Copy link
Contributor

end-4 commented Aug 30, 2023

just going to add that this also occurs when the child of the Window is a Revealer with revealChild set to false + a connection like this

connections: [[App, (revealer, name, visible) => {
    if (name !== 'windowname')
        return;
    if (visible)
        revealer.set_reveal_child(true);
    else
        revealer.set_reveal_child(false);
}]],

@musjj
Copy link
Contributor

musjj commented Feb 15, 2024

the window is shown after the command run the third time only and not the first

I'm also having this same problem, but only when one of the child of the window is a revealer. Does anyone have a working minimal example of a toggle-able revealer widget?

@musjj
Copy link
Contributor

musjj commented Feb 15, 2024

Wow, it looks like that you need to put the Revealer into a Box that has a padding: 1px like this:

Widget.Box({
  css: "padding: 1px;",
  child: Widget.Revealer({
    ...
  }),
});

I've only figured this out after digging through @Aylur's dotfiles. Anyone know what's going on behind this witchcraft?

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

No branches or pull requests

4 participants